mirror of
https://github.com/python/cpython.git
synced 2025-09-19 07:00:59 +00:00
gh-67224: Show source lines in tracebacks when using the -c option when running Python (#111200)
This commit is contained in:
parent
3f84a19e62
commit
90a1b2859f
13 changed files with 104 additions and 36 deletions
|
@ -684,6 +684,16 @@ class CmdLineTest(unittest.TestCase):
|
|||
]
|
||||
)
|
||||
|
||||
def test_source_lines_are_shown_when_running_source(self):
|
||||
_, _, stderr = assert_python_failure("-c", "1/0")
|
||||
expected_lines = [
|
||||
b'Traceback (most recent call last):',
|
||||
b' File "<string>", line 1, in <module>',
|
||||
b' 1/0',
|
||||
b' ~^~',
|
||||
b'ZeroDivisionError: division by zero']
|
||||
self.assertEqual(stderr.splitlines(), expected_lines)
|
||||
|
||||
def test_syntaxerror_does_not_crash(self):
|
||||
script = "nonlocal x\n"
|
||||
with os_helper.temp_dir() as script_dir:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue