]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-41718: regrtest saved_test_environment avoids imports (GH-24934)
authorVictor Stinner <vstinner@python.org>
Mon, 22 Mar 2021 22:52:13 +0000 (23:52 +0100)
committerGitHub <noreply@github.com>
Mon, 22 Mar 2021 22:52:13 +0000 (23:52 +0100)
commit532e063fc2bf9e6e80550670ddc5dc5d2b1d2450
tree599921f509708f9d212cd64d118df28b272f80ba
parent96eeff516204b7cc751103fa33dcc665e387846e
bpo-41718: regrtest saved_test_environment avoids imports (GH-24934)

Reduce the number of modules imported by libregrtest.

saved_test_environment no longer imports modules at startup, but try
to get them from sys.modules. If an module is missing, skip the test.
It also sets directly support.environment_altered.

runtest() now now two saved_test_environment instances: one before
importing the test module, one after importing it.

Remove imports from test.libregrtest.save_env:

* asyncio
* logging
* multiprocessing
* shutil
* sysconfig
* urllib.request
* warnings

When a test method imports a module (ex: warnings) and the test
has a side effect (ex: add a warnings filter), the side effect is not
detected, because the module was not imported when Python
enters the saved_test_environment context manager.
Lib/test/libregrtest/runtest.py
Lib/test/libregrtest/save_env.py