summaryrefslogtreecommitdiff
path: root/Lib/test/test_inspect.py
diff options
context:
space:
mode:
authorJohannes Gijsbers <jlg@dds.nl>2005-03-12 16:37:11 +0000
committerJohannes Gijsbers <jlg@dds.nl>2005-03-12 16:37:11 +0000
commita5855d5ace1c1426e1247272c688ccc11ae02f7c (patch)
treec841015eced138476cf55a5aaf22942cd37884b6 /Lib/test/test_inspect.py
parentf77d0334f30e331f005090723cd1d2955959a8cd (diff)
downloadcpython-git-a5855d5ace1c1426e1247272c688ccc11ae02f7c.tar.gz
Patch #1159931/bug #1143895: inspect.getsource failed when functions,
etc., had comments after the colon, and some other cases. This patch take a simpler approach that doesn't rely on looking for a ':'. Thanks Simon Percivall!
Diffstat (limited to 'Lib/test/test_inspect.py')
-rw-r--r--Lib/test/test_inspect.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 9e60a9c712..1fb48c526d 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -229,6 +229,15 @@ class TestOneliners(GetSourceBase):
# as argument to another function.
self.assertSourceEqual(mod2.anonymous, 55, 55)
+class TestBuggyCases(GetSourceBase):
+ fodderFile = mod2
+
+ def test_with_comment(self):
+ self.assertSourceEqual(mod2.with_comment, 58, 59)
+
+ def test_multiline_sig(self):
+ self.assertSourceEqual(mod2.multiline_sig[0], 63, 64)
+
# Helper for testing classify_class_attrs.
def attrs_wo_objs(cls):
return [t[:3] for t in inspect.classify_class_attrs(cls)]
@@ -414,6 +423,7 @@ class TestClassesAndFunctions(unittest.TestCase):
def test_main():
run_unittest(TestDecorators, TestRetrievingSourceCode, TestOneliners,
+ TestBuggyCases,
TestInterpreterStack, TestClassesAndFunctions, TestPredicates)
if __name__ == "__main__":