|
19 | 19 | from test.support import force_not_colorized, os_helper |
20 | 20 | from test.support.import_helper import import_module |
21 | 21 | from test.support.pty_helper import run_pty, FakeInput |
| 22 | +from test.support.script_helper import kill_python |
22 | 23 | from unittest.mock import patch |
23 | 24 |
|
24 | 25 | SKIP_CORO_TESTS = False |
@@ -4342,6 +4343,29 @@ def test_quit(self): |
4342 | 4343 | self.assertEqual(stdout.count("Quit anyway"), 2) |
4343 | 4344 |
|
4344 | 4345 |
|
| 4346 | +@support.force_not_colorized_test_class |
| 4347 | +@support.requires_subprocess() |
| 4348 | +class TestREPLSession(unittest.TestCase): |
| 4349 | + def test_return_from_inline_mode_to_REPL(self): |
| 4350 | + # GH-124703: Raise BdbQuit when exiting pdb in REPL session. |
| 4351 | + # This allows the REPL session to continue. |
| 4352 | + from test.test_repl import spawn_repl |
| 4353 | + p = spawn_repl() |
| 4354 | + user_input = """ |
| 4355 | + x = 'Spam' |
| 4356 | + import pdb |
| 4357 | + pdb.set_trace(commands=['x + "During"', 'q']) |
| 4358 | + x + 'After' |
| 4359 | + """ |
| 4360 | + p.stdin.write(textwrap.dedent(user_input)) |
| 4361 | + output = kill_python(p) |
| 4362 | + self.assertIn('SpamDuring', output) |
| 4363 | + self.assertNotIn("Quit anyway", output) |
| 4364 | + self.assertIn('BdbQuit', output) |
| 4365 | + self.assertIn('SpamAfter', output) |
| 4366 | + self.assertEqual(p.returncode, 0) |
| 4367 | + |
| 4368 | + |
4345 | 4369 | @support.requires_subprocess() |
4346 | 4370 | class PdbTestReadline(unittest.TestCase): |
4347 | 4371 | def setUpClass(): |
|
0 commit comments