summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_inspect.py
diff options
context:
space:
mode:
authorMarco Buttu <marco.buttu@gmail.com>2017-03-17 08:50:23 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2017-03-17 08:50:23 (GMT)
commit3f2155ffe683080f2a1b28408fa48d43ba92f943 (patch)
tree278d84449342a3a31983440ea5645b28d3795ff7 /Lib/test/test_inspect.py
parent1bb0f3762ec5104014aeed0ae6e9d64598d8fcac (diff)
downloadcpython-3f2155ffe683080f2a1b28408fa48d43ba92f943.zip
cpython-3f2155ffe683080f2a1b28408fa48d43ba92f943.tar.gz
cpython-3f2155ffe683080f2a1b28408fa48d43ba92f943.tar.bz2
bpo-16355: Clarify when inspect.getcomments() returns None (#428)
Initial patch by Vajrasky Kok.
Diffstat (limited to 'Lib/test/test_inspect.py')
-rw-r--r--Lib/test/test_inspect.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 9d9fedc..2f12e98 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -384,6 +384,11 @@ class TestRetrievingSourceCode(GetSourceBase):
def test_getcomments(self):
self.assertEqual(inspect.getcomments(mod), '# line 1\n')
self.assertEqual(inspect.getcomments(mod.StupidGit), '# line 20\n')
+ # If the object source file is not available, return None.
+ co = compile('x=1', '_non_existing_filename.py', 'exec')
+ self.assertIsNone(inspect.getcomments(co))
+ # If the object has been defined in C, return None.
+ self.assertIsNone(inspect.getcomments(list))
def test_getmodule(self):
# Check actual module