[Python-checkins] cpython (3.3): Close #17731: Clean up properly in test_import
nick.coghlan
python-checkins at python.org
Mon Apr 15 14:58:07 CEST 2013
http://hg.python.org/cpython/rev/73c79022977b
changeset: 83390:73c79022977b
branch: 3.3
parent: 83379:65db865c0851
user: Nick Coghlan <ncoghlan at gmail.com>
date: Mon Apr 15 22:56:51 2013 +1000
summary:
Close #17731: Clean up properly in test_import
files:
Lib/test/test_import.py | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py
--- a/Lib/test/test_import.py
+++ b/Lib/test/test_import.py
@@ -43,6 +43,7 @@
# sets up a temporary directory and removes it
# creates the module file
# temporarily clears the module from sys.modules (if any)
+ # reverts or removes the module when cleaning up
name = name or "spam"
with script_helper.temp_dir() as tempdir:
path = script_helper.make_script(tempdir, name, source)
@@ -54,6 +55,8 @@
finally:
if old_module is not None:
sys.modules[name] = old_module
+ elif name in sys.modules:
+ del sys.modules[name]
class ImportTests(unittest.TestCase):
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list