summaryrefslogtreecommitdiffstats
path: root/Lib/test/support/import_helper.py
Commit message (Collapse)AuthorAgeFilesLines
* gh-76785: Rename _xxsubinterpreters to _interpreters (gh-117791)Eric Snow2024-04-241-1/+1
| | | See https://discuss.python.org/t/pep-734-multiple-interpreters-in-the-stdlib/41147/26.
* gh-116307: Proper fix for 'mod' leaking across importlib tests (#116680)Jason R. Coombs2024-03-121-0/+12
| | | gh-116307: Create a new import helper 'isolated modules' and use that instead of 'Clean Import' to ensure that tests from importlib_resources don't leave modules in sys.modules.
* gh-109625: Move _ready_to_import() from test_import to support.import_helper ↵Nikita Sobolev2023-09-211-1/+24
| | | | (#109626)
* gh-104310: Add importlib.util.allowing_all_extensions() (gh-104311)Eric Snow2023-05-081-0/+2
| | | (I'll be adding docs for this separately.)
* gh-98627: Add an Optional Check for Extension Module Subinterpreter ↵Eric Snow2023-02-161-0/+18
| | | | | | | | | | | | | | | Compatibility (gh-99040) Enforcing (optionally) the restriction set by PEP 489 makes sense. Furthermore, this sets the stage for a potential restriction related to a per-interpreter GIL. This change includes the following: * add tests for extension module subinterpreter compatibility * add _PyInterpreterConfig.check_multi_interp_extensions * add Py_RTFLAGS_MULTI_INTERP_EXTENSIONS * add _PyImport_CheckSubinterpIncompatibleExtensionAllowed() * fail iff the module does not implement multi-phase init and the current interpreter is configured to check https://github.com/python/cpython/issues/98627
* gh-97669: Fix test_tools reference leak (#98216)Victor Stinner2022-10-121-0/+8
| | | | | | | | test_tools.test_sundry() now uses an unittest mock to prevent the logging module to register a real "atfork" function which kept the logging module dictionary alive. So the logging module can be properly unloaded. Previously, the logging module was loaded before test_sundry(), but it's no longer the case since recent test_tools sub-tests removals.
* bpo-46678: Fix Invalid cross device link in ↵Jason Wilkes2022-02-081-1/+2
| | | | | | | Lib/test/support/import_helper.py (GH-31204) In [Lib/test/support/import_helper.py](https://github.com/python/cpython/blob/master/Lib/test/support/import_helper.py), the function `make_legacy_pyc` makes a call to `os.rename` which can fail when the source and target live on different devices. This happens (for example) when `PYTHONPYCACHEPREFIX` is set to a directory anywhere on disk, while a ramdisk is mounted on `/tmp` (the latter of which is the default on various Linux distros). Replacing `os.rename` with `shutil.move` fixes this. Automerge-Triggered-By: GH:brettcannon
* bpo-40173: Fix test.support.import_helper.import_fresh_module() (GH-28654)Serhiy Storchaka2021-09-301-43/+24
| | | | | | | | | | | | * Work correctly if an additional fresh module imports other additional fresh module which imports a blocked module. * Raises ImportError if the specified module cannot be imported while all additional fresh modules are successfully imported. * Support blocking packages. * Always restore the import state of fresh and blocked modules and their submodules. * Fix test_decimal and test_xml_etree which depended on an undesired side effect of import_fresh_module().
* bpo-45020: Add -X frozen_modules=[on|off] to explicitly control use of ↵Eric Snow2021-09-141-3/+31
| | | | | | | frozen modules. (gh-28320) Currently we freeze several modules into the runtime. For each of these modules it is essential to bootstrapping the runtime that they be frozen. Any other stdlib module that we later freeze into the runtime is not essential. We can just as well import from the .py file. This PR lets users explicitly choose which should be used, with the new "-X frozen_modules=[on|off]" CLI flag. The default is "off" for now. https://bugs.python.org/issue45020
* bpo-40275: Add import_helper submodule in test.support (GH-20794)Hai Shi2020-06-101-0/+238