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

Method test_header

Lib/test/test_pdb.py:4113–4125  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4111 self.assertEqual(pdb.Pdb().rcLines, ["invalid"])
4112
4113 def test_header(self):
4114 stdout = StringIO()
4115 header = 'Nobody expects... blah, blah, blah'
4116 with ExitStack() as resources:
4117 resources.enter_context(patch('sys.stdout', stdout))
4118 # patch pdb.Pdb.set_trace() to avoid entering the debugger
4119 resources.enter_context(patch.object(pdb.Pdb, 'set_trace'))
4120 # We need to manually clear pdb.Pdb._last_pdb_instance so a
4121 # new instance with stdout redirected could be created when
4122 # pdb.set_trace() is called.
4123 pdb.Pdb._last_pdb_instance = None
4124 pdb.set_trace(header=header)
4125 self.assertEqual(stdout.getvalue(), header + '\n')
4126
4127 def test_run_module(self):
4128 script = """print("SUCCESS")"""

Callers

nothing calls this directly

Calls 7

getvalueMethod · 0.95
StringIOClass · 0.90
ExitStackClass · 0.90
patchFunction · 0.90
enter_contextMethod · 0.80
set_traceMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected