https://github.com/python/cpython/commit/c0af6d4ff1705d9857c9f2e96acc142c5b8b84e9
commit: c0af6d4ff1705d9857c9f2e96acc142c5b8b84e9
branch: main
author: Tian Gao <[email protected]>
committer: gaogaotiantian <[email protected]>
date: 2024-07-13T11:55:22-07:00
summary:
gh-121651: Fix pdb header test (#121724)
files:
M Lib/test/test_pdb.py
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index 343e15a4edc14c..f71856d3603d73 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -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')
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]