From 7873884d4730d7e637a968011b8958bd79fd3398 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Thu, 30 Sep 2021 19:56:41 +0300 Subject: [3.10] bpo-40173: Fix test.support.import_helper.import_fresh_module() (GH-28654) (GH-28657) * 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(). (cherry picked from commit ec4d917a6a68824f1895f75d113add9410283da7) --- Lib/test/test_decimal.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Lib/test/test_decimal.py') diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index 99263bb13b..b6173a5ffe 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -62,7 +62,7 @@ if sys.platform == 'darwin': C = import_fresh_module('decimal', fresh=['_decimal']) P = import_fresh_module('decimal', blocked=['_decimal']) -orig_sys_decimal = sys.modules['decimal'] +import decimal as orig_sys_decimal # fractions module must import the correct decimal module. cfractions = import_fresh_module('fractions', fresh=['fractions']) -- cgit v1.2.1