This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Created on 2022-01-17 23:35 by BaderSZ, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 30654 merged BaderSZ, 2022-01-18 00:38
PR 31969 merged miss-islington, 2022-03-17 23:38
PR 31970 merged miss-islington, 2022-03-17 23:38
Messages (5)
msg410833 - (view) Author: Bader Zaidan (BaderSZ) * Date: 2022-01-17 23:35
When running a local unittest as a module (for example, `python -m unittest ./tests/*.py`), the command fails with a ValueError. However, if we remove the local directory definition, and call it as `python -m unittest tests/*.py`, it runs without issue. A GitHub pull request with a pull request will be sent promptly.
msg410834 - (view) Author: Bader Zaidan (BaderSZ) * Date: 2022-01-17 23:45
For reference, this is the error request: ``` python3 -m unittest ./tests/*.py Traceback (most recent call last): File "/usr/lib64/python3.10/runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib64/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/usr/lib64/python3.10/unittest/__main__.py", line 18, in <module> main(module=None) File "/usr/lib64/python3.10/unittest/main.py", line 100, in __init__ self.parseArgs(argv) File "/usr/lib64/python3.10/unittest/main.py", line 147, in parseArgs self.createTests() File "/usr/lib64/python3.10/unittest/main.py", line 158, in createTests self.test = self.testLoader.loadTestsFromNames(self.testNames, File "/usr/lib64/python3.10/unittest/loader.py", line 220, in loadTestsFromNames suites = [self.loadTestsFromName(name, module) for name in names] File "/usr/lib64/python3.10/unittest/loader.py", line 220, in <listcomp> suites = [self.loadTestsFromName(name, module) for name in names] File "/usr/lib64/python3.10/unittest/loader.py", line 154, in loadTestsFromName module = __import__(module_name) ValueError: Empty module name ``` The issue stems with having "." as its own value in the parts list of `unittest/loader.py`. https://github.com/python/cpython/blob/main/Lib/unittest/loader.py#L125
msg415461 - (view) Author: Jelle Zijlstra (JelleZijlstra) * (Python committer) Date: 2022-03-17 23:38
 New changeset a0db11b10fca0fee6bb2b8d6277e266bad8c0fdb by Bader Zaidan in branch 'main': bpo-46421: Fix unittest filename evaluation when called as a module (GH-30654) https://github.com/python/cpython/commit/a0db11b10fca0fee6bb2b8d6277e266bad8c0fdb 
msg415462 - (view) Author: miss-islington (miss-islington) Date: 2022-03-18 00:01
 New changeset 0b5f99ad1af0892a2d6043abd8aeb10d685d3844 by Miss Islington (bot) in branch '3.10': bpo-46421: Fix unittest filename evaluation when called as a module (GH-30654) https://github.com/python/cpython/commit/0b5f99ad1af0892a2d6043abd8aeb10d685d3844 
msg415468 - (view) Author: Jelle Zijlstra (JelleZijlstra) * (Python committer) Date: 2022-03-18 03:25
 New changeset 1cab44d8650ae3eece90b04fca373908205e7ee0 by Miss Islington (bot) in branch '3.9': [3.9] bpo-46421: Fix unittest filename evaluation when called as a module (GH-30654) (GH-31970) https://github.com/python/cpython/commit/1cab44d8650ae3eece90b04fca373908205e7ee0 
History
Date User Action Args
2022-04-11 14:59:54adminsetgithub: 90579
2022-03-18 03:25:14JelleZijlstrasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2022-03-18 03:25:04JelleZijlstrasetmessages: + msg415468
2022-03-18 00:01:05miss-islingtonsetmessages: + msg415462
2022-03-17 23:38:25miss-islingtonsetpull_requests: + pull_request30060
2022-03-17 23:38:20miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request30059
2022-03-17 23:38:00JelleZijlstrasetnosy: + JelleZijlstra
messages: + msg415461
2022-01-22 23:37:38BaderSZsetversions: + Python 3.7, Python 3.8
2022-01-22 09:01:00kumaradityasetnosy: + serhiy.storchaka, kumaraditya

type: behavior
versions: + Python 3.9, Python 3.11
2022-01-21 23:34:38terry.reedysetnosy: + rbcollins, ezio.melotti, michael.foord
2022-01-18 00:38:22BaderSZsetkeywords: + patch
stage: patch review
pull_requests: + pull_request28855
2022-01-17 23:45:52BaderSZsetmessages: + msg410834
2022-01-17 23:35:01BaderSZcreate