You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test_unittest failure triggered by test_import + test_importlib #108927
test_import imports test.test_importlib.util. 'test.test_importlib' and 'test.test_importlib.util' are now in sys.modules.
Somebody removes 'test.test_importlib' from sys.modules but leaves 'test.test_importlib.util'.
libregrtest imports test.test_importlib. test now has attribute test_importlib.
test_unittest.test_discovery requests to import test.test_importlib.util at import time, and since it is found in sys.modules, it simply sets module global test.
It now tries to access test.test_importlib.util. Global test has attribute test_importlib, but test.test_importlib has no attribute util.
Actually when I run just ./python -m test test_import test_importlib test_unittest I see this in 3.11.5 and 3.11.4 as well. But 3.11.4's test suite is succeeding on our CI. 3.11.6 is not.
Activity
pythongh-108927: Fix test_import + test_importlib + test_unittest pro…
serhiy-storchaka commentedon Sep 5, 2023
test.test_importlib.util.'test.test_importlib'and'test.test_importlib.util'are now insys.modules.'test.test_importlib'fromsys.modulesbut leaves'test.test_importlib.util'.test.test_importlib.testnow has attributetest_importlib.test.test_importlib.utilat import time, and since it is found insys.modules, it simply sets module globaltest.test.test_importlib.util. Globaltesthas attributetest_importlib, buttest.test_importlibhas no attributeutil.serhiy-storchaka commentedon Sep 5, 2023
libregrtest does this for every tested module. Now this sequence is clear:
test.test_importlib.util.test_importlib.test.test_importlib.util.You can use other tests which import
test.test_importlib.util, just addtest_importlibbetween two of such tests.pythongh-108927: Do not remove tested modules from sys.modules
pythongh-108927: Do not remove tested modules from sys.modules
serhiy-storchaka commentedon Sep 5, 2023
test_compileall yet one test which can fail after test_importlib.
Details
#108952 fixes all such cases.
gh-108927: Fix test_import + test_importlib + test_unittest problem (#…
pythongh-108927: Fix test_import + test_importlib + test_unittest pro…
[3.12] gh-108927: Fix test_import + test_importlib + test_unittest pr…
lordmauve commentedon Oct 4, 2023
I am also seeing this in the 3.11.6 release and can confirm that #108929 fixes it.
lordmauve commentedon Oct 4, 2023
Actually when I run just
./python -m test test_import test_importlib test_unittestI see this in 3.11.5 and 3.11.4 as well. But 3.11.4's test suite is succeeding on our CI. 3.11.6 is not.pythongh-108927: Fix test_import + test_importlib + test_unittest pro…
[3.11] gh-108927: Fix test_import + test_importlib + test_unittest pr…
2 remaining items
pythongh-108927: Fix removing testing modules from sys.modules (pytho…
[3.11] gh-108927: Fix removing testing modules from sys.modules (GH-1…
[3.12] gh-108927: Fix removing testing modules from sys.modules (GH-1…
vstinner commentedon Dec 4, 2023
Nice!
pythongh-108927: Include new dir test/regrtestdata in the installation
gh-108927: Include new dir test/regrtestdata in the installation (GH-…
[3.11] pythongh-108927: Include new dir test/regrtestdata in the inst…
[3.12] pythongh-108927: Include new dir test/regrtestdata in the inst…
[3.11] gh-108927: Include new dir test/regrtestdata in the installati…
[3.12] gh-108927: Include new dir test/regrtestdata in the installati…
pythongh-108927: Fix removing testing modules from sys.modules (pytho…
pythongh-108927: Include new dir test/regrtestdata in the installation (
pythongh-108927: Fix removing testing modules from sys.modules (pytho…
pythongh-108927: Include new dir test/regrtestdata in the installation (