-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
test_lib2to3 fails since Python 3.9 #86136
Comments
I am packaging Python for Arch and the tests suite of Python 3.8.6 pass here without this:
|
Same thing as in https://bugs.python.org/issue41971. I cannot reproduce this with a fresh install of 3.9 and our buildbots are not complaining about this. ownloads/Python-3.9.0 == Tests result: SUCCESS == 1 test OK. Total duration: 7.5 sec ------- ❯ ./lel/bin/python3 -m test test_lib2to3 == Tests result: SUCCESS == 1 test OK. Total duration: 7.4 sec |
I have also seen this and linked issue on running whole test suite while building python myself but running individual tests show no error and buildbots also never complained so I thought it's something wrong with my setup. I introduced the commit to silence deprecation warning due to lib2to3 and cannot reproduce the same running it individually. |
What I don't understand then is how the buildbots or the CI in Github that run all tests sequentially with the extra flags (-uall and friends) have not complained yet about this. @felix, how consistent is this failure you are experiencing? |
I just experienced the very same issue. Tell me if I can provide any useful information |
Pablo, I can see the error in Travis. The difference I can see is that the tests are executed sequentially in coverage run but normal run has tests executing in parallel. Felix and Federico, can you please add the command you use to run the tests? Sample error build : https://travis-ci.com/github/python/cpython/jobs/396688564#L2022 coverage run but has true in the end thus being always successful xvfb-run ./venv/bin/python -m coverage run --branch --pylib -m test --fail-env-changed -uall,-cpu -x test_multiprocessing_fork -x test_multiprocessing_forkserver -x test_multiprocessing_spawn -x test_concurrent_futures || true Normal run /home/travis/build/python/cpython/python -u -W default -bb -E -m test -r -w -j 1 -u all -W --slowest --fail-env-changed --timeout=1200 -j4 -uall,-cpu |
I use this in Arch's packaging: LC_CTYPE=en_US.UTF-8 xvfb-run -s "-screen 0 1920x1080x16 -ac +extension GLX" -a -n "$servernum" \
"${srcdir}/Python-${pkgver}/python" -m test.regrtest -v -uall -x test_tk (test_tk is currently skipped due to https://bugs.python.org/issue41306) |
I just run "python -m test" for it to fail and "python -m test test_lib2to3" for it to succeded. |
I can reproduce this by running test_lib2to3 twice or running test___all__ with test_lib2to3 ./python -m test test_lib2to3 test_lib2to3
0:00:00 load avg: 0.03 Run tests sequentially
0:00:00 load avg: 0.03 [1/2] test_lib2to3
0:00:13 load avg: 0.25 [2/2] test_lib2to3
test test_lib2to3 crashed -- Traceback (most recent call last):
File "/root/cpython/Lib/test/libregrtest/runtest.py", line 272, in _runtest_inner
refleak = _runtest_inner2(ns, test_name)
File "/root/cpython/Lib/test/libregrtest/runtest.py", line 223, in _runtest_inner2
the_module = importlib.import_module(abstest)
File "/root/cpython/Lib/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/root/cpython/Lib/test/test_lib2to3.py", line 5, in <module>
from lib2to3.tests import load_tests
File "/root/cpython/Lib/contextlib.py", line 124, in __exit__
next(self.gen)
File "/root/cpython/Lib/test/support/warnings_helper.py", line 179, in _filterwarnings
raise AssertionError("filter (%r, %s) did not catch any warning" %
AssertionError: filter ('', PendingDeprecationWarning) did not catch any warning test_lib2to3 failed == Tests result: FAILURE == 1 test OK. 1 test failed: Total duration: 13.5 sec ./python -m test test___all__ test_lib2to3
0:00:00 load avg: 0.05 Run tests sequentially
0:00:00 load avg: 0.05 [1/2] test___all__
0:00:00 load avg: 0.05 [2/2] test_lib2to3
test test_lib2to3 crashed -- Traceback (most recent call last):
File "/root/cpython/Lib/test/libregrtest/runtest.py", line 272, in _runtest_inner
refleak = _runtest_inner2(ns, test_name)
File "/root/cpython/Lib/test/libregrtest/runtest.py", line 223, in _runtest_inner2
the_module = importlib.import_module(abstest)
File "/root/cpython/Lib/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/root/cpython/Lib/test/test_lib2to3.py", line 5, in <module>
from lib2to3.tests import load_tests
File "/root/cpython/Lib/contextlib.py", line 124, in __exit__
next(self.gen)
File "/root/cpython/Lib/test/support/warnings_helper.py", line 179, in _filterwarnings
raise AssertionError("filter (%r, %s) did not catch any warning" %
AssertionError: filter ('', PendingDeprecationWarning) did not catch any warning test_lib2to3 failed == Tests result: FAILURE == 1 test OK. 1 test failed: Total duration: 1.1 sec |
I can have the test to fails if I run "python -m test test_lib2to3 test_lib2to3" as well |
Ok, thanks everyone for the help reproducing this. I think I can work on a fix today |
I guess this could be due to loading the module twice where the warning is not emitted again on reimport which test__all__ seems to do so by importing lib2to3. One obvious fix would be to pass quiet=True. Else we need to find a way to import the module fresh like using import_fresh_module. Two possible patches. I assumed running tests sequentially will provide support for isolation too.
# Using import fresh module diff --git a/Lib/test/test_lib2to3.py b/Lib/test/test_lib2to3.py
index 159a8387e4..861ae5ad53 100644
--- a/Lib/test/test_lib2to3.py
+++ b/Lib/test/test_lib2to3.py
@@ -1,7 +1,9 @@
import unittest
+from test.support.import_helper import import_fresh_module
from test.support.warnings_helper import check_warnings
with check_warnings(("", PendingDeprecationWarning)):
+ lib2to3 = import_fresh_module("lib2to3")
from lib2to3.tests import load_tests
if __name__ == '__main__': # Passing quiet=True diff --git a/Lib/test/test_lib2to3.py b/Lib/test/test_lib2to3.py
index 159a8387e4..e4c5cade8b 100644
--- a/Lib/test/test_lib2to3.py
+++ b/Lib/test/test_lib2to3.py
@@ -1,7 +1,7 @@
import unittest
from test.support.warnings_helper import check_warnings
-with check_warnings(("", PendingDeprecationWarning)):
+with check_warnings(("", PendingDeprecationWarning), quiet=True):
from lib2to3.tests import load_tests
if __name__ == '__main__': ➜ cpython git:(master) ✗ ./python -m test test_lib2to3 test_lib2to3 == Tests result: SUCCESS == All 2 tests OK. Total duration: 27.3 sec |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: