summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_inspect.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-07-08 11:48:46 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-07-08 11:48:46 (GMT)
commit5d62a61b58bc2d42a734be24f58e64ef18c04e76 (patch)
tree84e522bac7092931165a2c0648a14c4df95e7338 /Lib/test/test_inspect.py
parent6803855ecf8044e3e6065dd624891a0179071537 (diff)
downloadcpython-5d62a61b58bc2d42a734be24f58e64ef18c04e76.zip
cpython-5d62a61b58bc2d42a734be24f58e64ef18c04e76.tar.gz
cpython-5d62a61b58bc2d42a734be24f58e64ef18c04e76.tar.bz2
Fix test_inspect messing up with linecache.cache.
Diffstat (limited to 'Lib/test/test_inspect.py')
-rw-r--r--Lib/test/test_inspect.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 7ed4ffe..80db03b 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -285,7 +285,10 @@ class TestRetrievingSourceCode(GetSourceBase):
co = compile("None", fn, "exec")
self.assertEqual(inspect.getsourcefile(co), None)
linecache.cache[co.co_filename] = (1, None, "None", co.co_filename)
- self.assertEqual(normcase(inspect.getsourcefile(co)), fn)
+ try:
+ self.assertEqual(normcase(inspect.getsourcefile(co)), fn)
+ finally:
+ del linecache.cache[co.co_filename]
def test_getfile(self):
self.assertEqual(inspect.getfile(mod.StupidGit), mod.__file__)
@@ -407,8 +410,11 @@ class TestBuggyCases(GetSourceBase):
self.assertRaises(IOError, inspect.findsource, co)
self.assertRaises(IOError, inspect.getsource, co)
linecache.cache[co.co_filename] = (1, None, lines, co.co_filename)
- self.assertEqual(inspect.findsource(co), (lines,0))
- self.assertEqual(inspect.getsource(co), lines[0])
+ try:
+ self.assertEqual(inspect.findsource(co), (lines,0))
+ self.assertEqual(inspect.getsource(co), lines[0])
+ finally:
+ del linecache.cache[co.co_filename]
class TestNoEOL(GetSourceBase):
def __init__(self, *args, **kwargs):