Skip to content

gh-121651: Fix pdb header test #121724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Lib/test/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3389,7 +3389,12 @@ def test_header(self):
header = 'Nobody expects... blah, blah, blah'
with ExitStack() as resources:
resources.enter_context(patch('sys.stdout', stdout))
# patch pdb.Pdb.set_trace() to avoid entering the debugger
resources.enter_context(patch.object(pdb.Pdb, 'set_trace'))
# We need to manually clear pdb.Pdb._last_pdb_instance so a
# new instance with stdout redirected could be created when
# pdb.set_trace() is called.
pdb.Pdb._last_pdb_instance = None
pdb.set_trace(header=header)
self.assertEqual(stdout.getvalue(), header + '\n')

Expand Down
Loading