From: Tian Gao Date: Sat, 13 Jul 2024 18:55:22 +0000 (-0700) Subject: gh-121651: Fix pdb header test (#121724) X-Git-Tag: v3.14.0a1~1148 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c0af6d4ff1705d9857c9f2e96acc142c5b8b84e9;p=thirdparty%2FPython%2Fcpython.git gh-121651: Fix pdb header test (#121724) --- diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py index 343e15a4edc1..f71856d3603d 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')