Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Lib/test/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -4342,6 +4342,32 @@ def test_quit(self):
# The quit prompt should be printed exactly twice
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):
"""GH-82897
Inline set_trace() should break unconditionally. This example is a
Expand Down
Loading