summaryrefslogtreecommitdiff
path: root/Lib/test/test_inspect.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-06-11 15:56:46 -0500
committerBenjamin Peterson <benjamin@python.org>2011-06-11 15:56:46 -0500
commit703f7c4bf5fa98f9b8b11593d3fa37eb68eae896 (patch)
treea4fe76c58a8cc614a02aaaed497289fcfc345934 /Lib/test/test_inspect.py
parent3ae42726d4ba3a304d42f0c7df039de777a678bb (diff)
parent9620cc04634e720d1d016cce4bf02e0c27607e64 (diff)
downloadcpython-git-703f7c4bf5fa98f9b8b11593d3fa37eb68eae896.tar.gz
merge 3.2 (#9284)
Diffstat (limited to 'Lib/test/test_inspect.py')
-rw-r--r--Lib/test/test_inspect.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index f5dff1e543..7666fe43a7 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -298,6 +298,23 @@ class TestRetrievingSourceCode(GetSourceBase):
del sys.modules[name]
inspect.getmodule(compile('a=10','','single'))
+ def test_proceed_with_fake_filename(self):
+ '''doctest monkeypatches linecache to enable inspection'''
+ fn, source = '<test>', 'def x(): pass\n'
+ getlines = linecache.getlines
+ def monkey(filename, module_globals=None):
+ if filename == fn:
+ return source.splitlines(True)
+ else:
+ return getlines(filename, module_globals)
+ linecache.getlines = monkey
+ try:
+ ns = {}
+ exec(compile(source, fn, 'single'), ns)
+ inspect.getsource(ns["x"])
+ finally:
+ linecache.getlines = getlines
+
class TestDecorators(GetSourceBase):
fodderModule = mod2