MCPcopy Index your code
hub / github.com/python/cpython / test_getsource

Method test_getsource

Lib/test/test_inspect/test_inspect.py:6624–6635  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

6622
6623 @unittest.skipIf(not has_subprocess_support, "test requires subprocess")
6624 def test_getsource(self):
6625 output = self.run_on_interactive_mode(textwrap.dedent("""\
6626 def f():
6627 print(0)
6628 return 1 + 2
6629
6630 import inspect
6631 print(f"The source is: <<<{inspect.getsource(f)}>>>")
6632 """))
6633
6634 expected = "The source is: <<<def f():\n print(0)\n return 1 + 2\n>>>"
6635 self.assertIn(expected, output)
6636
6637
6638

Callers

nothing calls this directly

Calls 3

assertInMethod · 0.80
dedentMethod · 0.45

Tested by

no test coverage detected