summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTian Gao <gaogaotiantian@hotmail.com>2024-07-13 18:55:22 (GMT)
committerGitHub <noreply@github.com>2024-07-13 18:55:22 (GMT)
commitc0af6d4ff1705d9857c9f2e96acc142c5b8b84e9 (patch)
tree9ff3095fa2369cfc8f36ca7c805831843d3be4d9
parenta640a605a8a1a3f73b98f948d0c2a7d42134f692 (diff)
downloadcpython-c0af6d4ff1705d9857c9f2e96acc142c5b8b84e9.zip
cpython-c0af6d4ff1705d9857c9f2e96acc142c5b8b84e9.tar.gz
cpython-c0af6d4ff1705d9857c9f2e96acc142c5b8b84e9.tar.bz2
gh-121651: Fix pdb header test (#121724)
-rw-r--r--Lib/test/test_pdb.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index 343e15a..f71856d 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -3389,7 +3389,12 @@ def bœr():
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')