From ff0e3b7a54673791bb724be9679c85a4feb7468c Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Mon, 2 Jan 2017 06:57:43 +0300 Subject: Issue #15812: inspect.getframeinfo() now correctly shows the first line of a context Patch by Sam Breese. --- Lib/test/test_inspect.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Lib/test/test_inspect.py') diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py index 671e05a7b5..d33de9e5bc 100644 --- a/Lib/test/test_inspect.py +++ b/Lib/test/test_inspect.py @@ -391,6 +391,11 @@ class TestRetrievingSourceCode(GetSourceBase): # Check filename override self.assertEqual(inspect.getmodule(None, modfile), mod) + def test_getframeinfo_get_first_line(self): + frame_info = inspect.getframeinfo(self.fodderModule.fr, 50) + self.assertEqual(frame_info.code_context[0], "# line 1\n") + self.assertEqual(frame_info.code_context[1], "'A module docstring.'\n") + def test_getsource(self): self.assertSourceEqual(git.abuse, 29, 39) self.assertSourceEqual(mod.StupidGit, 21, 51) -- cgit v1.2.1