diff --git a/Lib/test/support.py b/Lib/test/support.py --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -172,6 +172,9 @@ if not _save_and_block_module(blocked_name, orig_modules): names_to_remove.append(blocked_name) fresh_module = importlib.import_module(name) + # Keep a reference to "freshly" imported modules + # (Workaround issue #812369) + fresh_module.__fresh = sys.modules.copy() except ImportError: fresh_module = None finally: