Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d340543

Browse files
committed
Do a better job of ensuring test reproducibility and clean up.
1 parent 82c1c78 commit d340543

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

Lib/test/test_importlib/import_/test_path.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,18 @@ def test_None_on_sys_path(self):
9898
new_path_hooks = [zipimport.zipimporter,
9999
_bootstrap.FileFinder.path_hook(
100100
*_bootstrap._get_supported_file_loaders())]
101-
with util.uncache('email'):
101+
missing = object()
102+
email = sys.modules.pop('email', missing)
103+
try:
102104
with util.import_state(meta_path=sys.meta_path[:],
103105
path=new_path,
104106
path_importer_cache=new_path_importer_cache,
105107
path_hooks=new_path_hooks):
106108
module = import_module('email')
107109
self.assertIsInstance(module, ModuleType)
110+
finally:
111+
if email is not missing:
112+
sys.modules['email'] = email
108113

109114

110115
def test_main():

0 commit comments

Comments
 (0)