[Python-checkins] python/dist/src/Lib/test inspect_fodder2.py, 1.3, 1.4 test_inspect.py, 1.19, 1.20

jlgijsbers at users.sourceforge.net jlgijsbers at users.sourceforge.net
Sat Mar 12 17:37:14 CET 2005


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2176/test

Modified Files:
	inspect_fodder2.py test_inspect.py 
Log Message:
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!


Index: inspect_fodder2.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/inspect_fodder2.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- inspect_fodder2.py	7 Jan 2005 16:01:23 -0000	1.3
+++ inspect_fodder2.py	12 Mar 2005 16:37:11 -0000	1.4
@@ -53,3 +53,14 @@
 def setfunc(func):
     globals()["anonymous"] = func
 setfunc(lambda x, y: x*y)
+
+# line 57
+def with_comment():  # hello
+    world
+
+# line 61
+multiline_sig = [
+    lambda (x,
+            y): x+y,
+    None,
+    ]

Index: test_inspect.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_inspect.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- test_inspect.py	7 Jan 2005 16:01:23 -0000	1.19
+++ test_inspect.py	12 Mar 2005 16:37:11 -0000	1.20
@@ -229,6 +229,15 @@
         # 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 @@
 
 def test_main():
     run_unittest(TestDecorators, TestRetrievingSourceCode, TestOneliners,
+                 TestBuggyCases,
                  TestInterpreterStack, TestClassesAndFunctions, TestPredicates)
 
 if __name__ == "__main__":



More information about the Python-checkins mailing list