summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2013-04-15 12:57:57 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2013-04-15 12:57:57 (GMT)
commitd25e7de4a18675170345e7fccaed5810889589f2 (patch)
treebf2dde832d619b79a6600ec1ba6a7893f2b3c2da
parent66940a11f873283be64bb09675c07f718f846fa1 (diff)
parentf1465f0535ee64ee4bdcabe332c28943f579c672 (diff)
downloadcpython-d25e7de4a18675170345e7fccaed5810889589f2.zip
cpython-d25e7de4a18675170345e7fccaed5810889589f2.tar.gz
cpython-d25e7de4a18675170345e7fccaed5810889589f2.tar.bz2
Merge fix for #17731 from 3.3
-rw-r--r--Lib/test/test_import.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py
index 81ddf45..470a6d2 100644
--- a/Lib/test/test_import.py
+++ b/Lib/test/test_import.py
@@ -43,6 +43,7 @@ def _ready_to_import(name=None, source=""):
# 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 @@ def _ready_to_import(name=None, source=""):
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):