Skip to content

Commit c0af6d4

Browse files
gh-121651: Fix pdb header test (#121724)
1 parent a640a60 commit c0af6d4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Lib/test/test_pdb.py

+5
Original file line numberDiff line numberDiff line change
@@ -3389,7 +3389,12 @@ def test_header(self):
33893389
header = 'Nobody expects... blah, blah, blah'
33903390
with ExitStack() as resources:
33913391
resources.enter_context(patch('sys.stdout', stdout))
3392+
# patch pdb.Pdb.set_trace() to avoid entering the debugger
33923393
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
33933398
pdb.set_trace(header=header)
33943399
self.assertEqual(stdout.getvalue(), header + '\n')
33953400

0 commit comments

Comments
 (0)