gh-130660: Add a test for pdb when user quits after interact command (#130852)

This commit is contained in:
Tian Gao 2025-03-04 15:10:32 -05:00 committed by GitHub
parent dc6d66f44c
commit e20e47dda6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 26 additions and 0 deletions

View File

@ -4342,6 +4342,32 @@ def test_quit(self):
# The quit prompt should be printed exactly twice # The quit prompt should be printed exactly twice
self.assertEqual(stdout.count("Quit anyway"), 2) self.assertEqual(stdout.count("Quit anyway"), 2)
def test_quit_after_interact(self):
"""
interact command will set sys.ps1 temporarily, we need to make sure
that it's restored and pdb does not believe it's in interactive mode
after interact is done.
"""
script = """
x = 1
breakpoint()
"""
commands = """
interact
quit()
q
y
"""
stdout, stderr = self._run_script(script, commands)
# Normal exit should not print anything to stderr
self.assertEqual(stderr, "")
# The quit prompt should be printed exactly once
self.assertEqual(stdout.count("Quit anyway"), 1)
# BdbQuit should not be printed
self.assertNotIn("BdbQuit", stdout)
def test_set_trace_with_skip(self): def test_set_trace_with_skip(self):
"""GH-82897 """GH-82897
Inline set_trace() should break unconditionally. This example is a Inline set_trace() should break unconditionally. This example is a