diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2017-03-17 11:59:16 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-17 11:59:16 (GMT) |
commit | 948171bf999cf8b3e12048851041d2e04ae3a78c (patch) | |
tree | 9765c22574c621846c1dc717b0fc73b09dd0b22f /Lib/test | |
parent | 7c2081122c2a6b8ea27c3111da7f19f7824fe18a (diff) | |
download | cpython-948171bf999cf8b3e12048851041d2e04ae3a78c.zip cpython-948171bf999cf8b3e12048851041d2e04ae3a78c.tar.gz cpython-948171bf999cf8b3e12048851041d2e04ae3a78c.tar.bz2 |
bpo-16355: Clarify when inspect.getcomments() returns None (#428) (#690)
Initial patch by Vajrasky Kok.
(cherry picked from commit 3f2155ffe683080f2a1b28408fa48d43ba92f943)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_inspect.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py index 88eaabe..cfea281 100644 --- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -387,6 +387,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 |