Skip to content

Commit e28071a

Browse files
committed
Add PTY test
1 parent ac8d177 commit e28071a

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

‎Lib/test/test_pyrepl/test_pyrepl.py‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2102,6 +2102,31 @@ def setUp(self):
21022102
self.addCleanup(patcher.stop)
21032103
patcher.start()
21042104

2105+
def test_statement_submitted_hook_exception(self):
2106+
env = make_clean_env()
2107+
env["NO_COLOR"] = "1"
2108+
output, exit_code = self.run_repl(
2109+
[
2110+
"from _pyrepl import simple_interact as si",
2111+
"def hook(statement): raise RuntimeError('hook failed')",
2112+
"",
2113+
"si.statement_submitted_hook = hook",
2114+
"x = 1",
2115+
"print('executed:', x)",
2116+
"exit",
2117+
],
2118+
env=env,
2119+
skip=True,
2120+
)
2121+
2122+
output = output.replace("\r\n", "\n")
2123+
self.assertEqual(exit_code, 0)
2124+
self.assertEqual(
2125+
output.count("Error in statement_submitted_hook:\n"), 2
2126+
)
2127+
self.assertEqual(output.count("RuntimeError: hook failed"), 2)
2128+
self.assertIn("\nexecuted: 1\n", output)
2129+
21052130
@force_not_colorized
21062131
def test_exposed_globals_in_repl(self):
21072132
pre = "['__builtins__'"

0 commit comments

Comments
 (0)