diff options
Diffstat (limited to 'Lib/test/test_pyrepl/test_pyrepl.py')
-rw-r--r-- | Lib/test/test_pyrepl/test_pyrepl.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_pyrepl/test_pyrepl.py b/Lib/test/test_pyrepl/test_pyrepl.py index 3c4cc4b..c0d657e 100644 --- a/Lib/test/test_pyrepl/test_pyrepl.py +++ b/Lib/test/test_pyrepl/test_pyrepl.py @@ -112,6 +112,7 @@ class ReplTestCase(TestCase): else: os.close(master_fd) process.kill() + process.wait(timeout=SHORT_TIMEOUT) self.fail(f"Timeout while waiting for output, got: {''.join(output)}") os.close(master_fd) @@ -1564,6 +1565,27 @@ class TestMain(ReplTestCase): self.assertEqual(exit_code, 0) self.assertNotIn("\\040", pathlib.Path(hfile.name).read_text()) + def test_history_survive_crash(self): + env = os.environ.copy() + commands = "1\nexit()\n" + output, exit_code = self.run_repl(commands, env=env) + if "can't use pyrepl" in output: + self.skipTest("pyrepl not available") + + with tempfile.NamedTemporaryFile() as hfile: + env["PYTHON_HISTORY"] = hfile.name + commands = "spam\nimport time\ntime.sleep(1000)\npreved\n" + try: + self.run_repl(commands, env=env) + except AssertionError: + pass + + history = pathlib.Path(hfile.name).read_text() + self.assertIn("spam", history) + self.assertIn("time", history) + self.assertNotIn("sleep", history) + self.assertNotIn("preved", history) + def test_keyboard_interrupt_after_isearch(self): output, exit_code = self.run_repl(["\x12", "\x03", "exit"]) self.assertEqual(exit_code, 0) |