New submission from STINNER Victor <vstin...@python.org>:
Follow-up of bpo-40275. While investigating a crash on AIX (bpo-40068), I noticed that test_threading crashed because the test imports the logging module, and the logging has a bug on AIX on fork. I created an issue to reduce the number of imports made by "import test.support": https://bugs.python.org/issue40275 I would prefer to better isolate tests: test_threading should only test the threading module, not the logging module. Thanks to the hard work of Hai Shi, "import test.support" now imports only 37 modules instead of 171! He split the 3200 lines of Lib/test/support/__init__.py into new helper submodules: bytecode, import, threading, socket, etc. For example, TESTFN now comes from test.support.os_helper. Sadly, test.regrtest.save_env still imports asyncio and multiprocessing, and so in practice, running any test using "python -m test (...)" still imports around 233 modules :-( I measured the number of imports done in practice using the following file, Lib/test/test_sys_modules.py: ---- import unittest from test import support import sys class Tests(unittest.TestCase): def test_bug(self): modules = sorted(sys.modules) print("sys.modules:") print("") import pprint pprint.pprint(modules) print("") print("len(sys.modules):", len(modules)) def test_main(): support.run_unittest(Tests) if __name__ == "__main__": test_main() ---- master: * ./python -m test test_sys_modules: 233 modules (multiprocessing, asyncio, etc.) * ./python Lib/test/test_sys_modules.py: 95 modules 3.9: * ./python -m test test_sys_modules: 232 * ./python Lib/test/test_sys_modules.py: 117 3.5: * ./python -m test test_sys_modules: 167 * ./python Lib/test/test_sys_modules.py: 151 2.7: * ./python -m test test_sys_modules: 170 * ./python Lib/test/test_sys_modules.py: 122 ---------- components: Tests messages: 376374 nosy: shihai1991, vstinner priority: normal severity: normal status: open title: test.regrtest has way too many imports versions: Python 3.10 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue41718> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com