Skip to content

Bug in regrtest when name in SPLITTESTDIRS also matches a module name in tests #109402

Closed
@sobolevn

Description

@sobolevn

Bug report

During #109368 I tried to create Lib/test/test_future/ directory. It did not go well:

» ./python.exe -m test test_future
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/runpy.py", line 198, in _run_module_as_main
    return _run_code(code, main_globals, None,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/runpy.py", line 88, in _run_code
    exec(code, run_globals)
  File "/Users/sobolev/Desktop/cpython/Lib/test/__main__.py", line 2, in <module>
    main()
  File "/Users/sobolev/Desktop/cpython/Lib/test/libregrtest/main.py", line 511, in main
    Regrtest(ns).main(tests=tests)
  File "/Users/sobolev/Desktop/cpython/Lib/test/libregrtest/main.py", line 492, in main
    selected, tests = self.find_tests(tests)
                      ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/libregrtest/main.py", line 176, in find_tests
    alltests = findtests(testdir=self.test_dir,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/libregrtest/findtests.py", line 45, in findtests
    tests.extend(findtests(testdir=subdir, exclude=exclude,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/libregrtest/findtests.py", line 45, in findtests
    tests.extend(findtests(testdir=subdir, exclude=exclude,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/libregrtest/findtests.py", line 38, in findtests
    for name in os.listdir(testdir):
                ^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/Users/sobolev/Desktop/cpython/Lib/test/test_future/test_future'

I renamed Lib/test/test_future/test_future.py to Lib/test/test_future/test_import_future.py
Now I get a new error (but similar):

» ./python.exe -m test test_future
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/runpy.py", line 198, in _run_module_as_main
    return _run_code(code, main_globals, None,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/runpy.py", line 88, in _run_code
    exec(code, run_globals)
  File "/Users/sobolev/Desktop/cpython/Lib/test/__main__.py", line 2, in <module>
    main()
  File "/Users/sobolev/Desktop/cpython/Lib/test/libregrtest/main.py", line 511, in main
    Regrtest(ns).main(tests=tests)
  File "/Users/sobolev/Desktop/cpython/Lib/test/libregrtest/main.py", line 492, in main
    selected, tests = self.find_tests(tests)
                      ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/libregrtest/main.py", line 176, in find_tests
    alltests = findtests(testdir=self.test_dir,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/libregrtest/findtests.py", line 45, in findtests
    tests.extend(findtests(testdir=subdir, exclude=exclude,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/libregrtest/findtests.py", line 45, in findtests
    tests.extend(findtests(testdir=subdir, exclude=exclude,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/libregrtest/findtests.py", line 38, in findtests
    for name in os.listdir(testdir):
                ^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/Users/sobolev/Desktop/cpython/Lib/test/test_concurrent_futures/test_future'

This looks like a bug to me.

Linked PRs

Metadata

Metadata

Assignees

Labels

testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions