bpo-41718: regrtest saved_test_environment avoids imports by vstinner · Pull Request #24934 · python/cpython

@vstinner

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

This change may miss some bugs in tests, but it reduces the number of
modules imported by libregrtest.

shihai1991