summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_import.py
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2010-05-15 22:20:16 (GMT)
committerBrett Cannon <bcannon@gmail.com>2010-05-15 22:20:16 (GMT)
commit93220d0df11a5cbdc460db8e0e6b4d6967e022eb (patch)
tree83f4d2ded760e9272c0d5487775b6e8a813ec6f3 /Lib/test/test_import.py
parentc5605ba14421ab84c3c771f37890dd7935626bde (diff)
downloadcpython-93220d0df11a5cbdc460db8e0e6b4d6967e022eb.zip
cpython-93220d0df11a5cbdc460db8e0e6b4d6967e022eb.tar.gz
cpython-93220d0df11a5cbdc460db8e0e6b4d6967e022eb.tar.bz2
A test was not guaranteeing cleanup in the face of an exception.
Diffstat (limited to 'Lib/test/test_import.py')
-rw-r--r--Lib/test/test_import.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py
index 0a21e18..2ea6736 100644
--- a/Lib/test/test_import.py
+++ b/Lib/test/test_import.py
@@ -163,13 +163,14 @@ class ImportTests(unittest.TestCase):
# Need to be able to load from current dir.
sys.path.append('')
- # This used to crash.
- exec('import ' + module)
-
- # Cleanup.
- del sys.path[-1]
- unlink(filename + 'c')
- unlink(filename + 'o')
+ try:
+ # This used to crash.
+ exec('import ' + module)
+ finally:
+ # Cleanup.
+ del sys.path[-1]
+ unlink(filename + 'c')
+ unlink(filename + 'o')
def test_failing_import_sticks(self):
source = TESTFN + ".py"