diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-10-06 20:52:37 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-10-06 20:52:37 (GMT) |
commit | ab5a58d82732d94314160407112d8c609b7ad86b (patch) | |
tree | 24a6fe18b6fc8e7ec2944dc4d1fc9a1e2e63e61f /Lib | |
parent | 7c679514a506c485240e917c52e49a59e02bd122 (diff) | |
download | cpython-ab5a58d82732d94314160407112d8c609b7ad86b.zip cpython-ab5a58d82732d94314160407112d8c609b7ad86b.tar.gz cpython-ab5a58d82732d94314160407112d8c609b7ad86b.tar.bz2 |
test_import.test_module_with_large_stack(): unload the test module
Ensure that the module is unloaded to be able to run the test more than once,
and to not leak memory.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_import.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py index 9d15a43..a61ee2b 100644 --- a/Lib/test/test_import.py +++ b/Lib/test/test_import.py @@ -149,16 +149,24 @@ class ImportTests(unittest.TestCase): sys.path.append('') importlib.invalidate_caches() + namespace = {} try: make_legacy_pyc(filename) # This used to crash. - exec('import ' + module) + exec('import ' + module, None, namespace) finally: # Cleanup. del sys.path[-1] unlink(filename + 'c') unlink(filename + 'o') + # Remove references to the module (unload the module) + namespace.clear() + try: + del sys.modules[module] + except KeyError: + pass + def test_failing_import_sticks(self): source = TESTFN + ".py" with open(source, "w") as f: |