Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sobolevn opened this issue Sep 14, 2023 · 0 comments
Closed
Assignees
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

sobolevn commented Sep 14, 2023

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

@sobolevn sobolevn added type-bug An unexpected behavior, bug, or error tests Tests in the Lib/test dir labels Sep 14, 2023
@sobolevn sobolevn self-assigned this Sep 14, 2023
vstinner added a commit to vstinner/cpython that referenced this issue Sep 14, 2023
Check for the full module name in SPLITTESTDIRS, not the relative
module name.
vstinner added a commit to vstinner/cpython that referenced this issue Sep 14, 2023
Check for the full module name in SPLITTESTDIRS, not the relative
module name.
sobolevn added a commit to sobolevn/cpython that referenced this issue Sep 14, 2023
vstinner added a commit that referenced this issue Sep 14, 2023
Check for the full module name in SPLITTESTDIRS, not the relative
module name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant