summaryrefslogtreecommitdiff
path: root/Lib/test/test_inspect.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2015-04-15 00:41:29 +0200
committerAntoine Pitrou <solipsis@pitrou.net>2015-04-15 00:41:29 +0200
commita760001c2461bfd0dd0e922df209f23d45bf9688 (patch)
treeab488eef391f119f82aab86e1ac94677a4e3e947 /Lib/test/test_inspect.py
parent939f1aef8f4e34c96ae538b4337a849040cfb647 (diff)
downloadcpython-a760001c2461bfd0dd0e922df209f23d45bf9688.tar.gz
Issue #21217: inspect.getsourcelines() now tries to compute the start and
end lines from the code object, fixing an issue when a lambda function is used as decorator argument. Patch by Thomas Ballinger.
Diffstat (limited to 'Lib/test/test_inspect.py')
-rw-r--r--Lib/test/test_inspect.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 76f2b47401..9e1f546be7 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -392,6 +392,9 @@ class TestRetrievingSourceCode(GetSourceBase):
finally:
linecache.getlines = getlines
+ def test_getsource_on_code_object(self):
+ self.assertSourceEqual(mod.eggs.__code__, 12, 18)
+
class TestDecorators(GetSourceBase):
fodderModule = mod2
@@ -402,7 +405,10 @@ class TestDecorators(GetSourceBase):
self.assertSourceEqual(mod2.gone, 9, 10)
def test_getsource_unwrap(self):
- self.assertSourceEqual(mod2.real, 122, 124)
+ self.assertSourceEqual(mod2.real, 130, 132)
+
+ def test_decorator_with_lambda(self):
+ self.assertSourceEqual(mod2.func114, 113, 115)
class TestOneliners(GetSourceBase):
fodderModule = mod2
@@ -497,6 +503,9 @@ class TestBuggyCases(GetSourceBase):
self.assertRaises(IOError, inspect.findsource, co)
self.assertRaises(IOError, inspect.getsource, co)
+ def test_getsource_on_method(self):
+ self.assertSourceEqual(mod2.ClassWithMethod.method, 118, 119)
+
class TestNoEOL(GetSourceBase):
def __init__(self, *args, **kwargs):
self.tempdir = TESTFN + '_dir'