Skip to content

Commit e20e47d

Browse files
gh-130660: Add a test for pdb when user quits after interact command (#130852)
1 parent dc6d66f commit e20e47d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Lib/test/test_pdb.py

+26
Original file line numberDiff line numberDiff line change
@@ -4342,6 +4342,32 @@ def test_quit(self):
43424342
# The quit prompt should be printed exactly twice
43434343
self.assertEqual(stdout.count("Quit anyway"), 2)
43444344

4345+
def test_quit_after_interact(self):
4346+
"""
4347+
interact command will set sys.ps1 temporarily, we need to make sure
4348+
that it's restored and pdb does not believe it's in interactive mode
4349+
after interact is done.
4350+
"""
4351+
script = """
4352+
x = 1
4353+
breakpoint()
4354+
"""
4355+
4356+
commands = """
4357+
interact
4358+
quit()
4359+
q
4360+
y
4361+
"""
4362+
4363+
stdout, stderr = self._run_script(script, commands)
4364+
# Normal exit should not print anything to stderr
4365+
self.assertEqual(stderr, "")
4366+
# The quit prompt should be printed exactly once
4367+
self.assertEqual(stdout.count("Quit anyway"), 1)
4368+
# BdbQuit should not be printed
4369+
self.assertNotIn("BdbQuit", stdout)
4370+
43454371
def test_set_trace_with_skip(self):
43464372
"""GH-82897
43474373
Inline set_trace() should break unconditionally. This example is a

0 commit comments

Comments
 (0)