mirror of
https://github.com/python/cpython.git
synced 2025-10-19 16:03:42 +00:00
gh-128231: Use runcode()
return value for failing early (GH-129488)
This commit is contained in:
parent
9f25c1f012
commit
7ed3dc6392
5 changed files with 40 additions and 3 deletions
|
@ -53,6 +53,19 @@ def test_multiple_statements_output(self):
|
|||
self.assertFalse(more)
|
||||
self.assertEqual(f.getvalue(), "1\n")
|
||||
|
||||
@force_not_colorized
|
||||
def test_multiple_statements_fail_early(self):
|
||||
console = InteractiveColoredConsole()
|
||||
code = dedent("""\
|
||||
raise Exception('foobar')
|
||||
print('spam&eggs')
|
||||
""")
|
||||
f = io.StringIO()
|
||||
with contextlib.redirect_stderr(f):
|
||||
console.runsource(code)
|
||||
self.assertIn('Exception: foobar', f.getvalue())
|
||||
self.assertNotIn('spam&eggs', f.getvalue())
|
||||
|
||||
def test_empty(self):
|
||||
namespace = {}
|
||||
code = ""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue