We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a640a60 commit c0af6d4Copy full SHA for c0af6d4
Lib/test/test_pdb.py
@@ -3389,7 +3389,12 @@ def test_header(self):
3389
header = 'Nobody expects... blah, blah, blah'
3390
with ExitStack() as resources:
3391
resources.enter_context(patch('sys.stdout', stdout))
3392
+ # patch pdb.Pdb.set_trace() to avoid entering the debugger
3393
resources.enter_context(patch.object(pdb.Pdb, 'set_trace'))
3394
+ # We need to manually clear pdb.Pdb._last_pdb_instance so a
3395
+ # new instance with stdout redirected could be created when
3396
+ # pdb.set_trace() is called.
3397
+ pdb.Pdb._last_pdb_instance = None
3398
pdb.set_trace(header=header)
3399
self.assertEqual(stdout.getvalue(), header + '\n')
3400
0 commit comments