summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2005-09-25 11:45:45 (GMT)
committerArmin Rigo <arigo@tunes.org>2005-09-25 11:45:45 (GMT)
commitdd5c023af56b9a424a3965364521c50b73308379 (patch)
treea5523abd7d1eb9bf44ca9722f4798d49b0497503 /Lib/test
parente9f8ec98d4cd4542b5d6c5870d56a1ce1ae5d03b (diff)
downloadcpython-dd5c023af56b9a424a3965364521c50b73308379.zip
cpython-dd5c023af56b9a424a3965364521c50b73308379.tar.gz
cpython-dd5c023af56b9a424a3965364521c50b73308379.tar.bz2
some more fixes and tests for inspect.getsource(), triggered by crashes
from the PyPy project as well as the SF bug #1295909.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/inspect_fodder2.py24
-rw-r--r--Lib/test/test_inspect.py12
2 files changed, 36 insertions, 0 deletions
diff --git a/Lib/test/inspect_fodder2.py b/Lib/test/inspect_fodder2.py
index f216c82..f150ec6 100644
--- a/Lib/test/inspect_fodder2.py
+++ b/Lib/test/inspect_fodder2.py
@@ -64,3 +64,27 @@ multiline_sig = [
y): x+y,
None,
]
+
+# line 68
+def func69():
+ class cls70:
+ def func71():
+ pass
+ return cls70
+extra74 = 74
+
+# line 76
+def func77(): pass
+(extra78, stuff78) = 'xy'
+extra79 = 'stop'
+
+# line 81
+class cls82:
+ def func83(): pass
+(extra84, stuff84) = 'xy'
+extra85 = 'stop'
+
+# line 87
+def func88():
+ # comment
+ return 90
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 1fb48c5..ce346b9 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -238,6 +238,18 @@ class TestBuggyCases(GetSourceBase):
def test_multiline_sig(self):
self.assertSourceEqual(mod2.multiline_sig[0], 63, 64)
+ def test_nested_class(self):
+ self.assertSourceEqual(mod2.func69().func71, 71, 72)
+
+ def test_one_liner_followed_by_non_name(self):
+ self.assertSourceEqual(mod2.func77, 77, 77)
+
+ def test_one_liner_dedent_non_name(self):
+ self.assertSourceEqual(mod2.cls82.func83, 83, 83)
+
+ def test_with_comment_instead_of_docstring(self):
+ self.assertSourceEqual(mod2.func88, 88, 90)
+
# Helper for testing classify_class_attrs.
def attrs_wo_objs(cls):
return [t[:3] for t in inspect.classify_class_attrs(cls)]