diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2023-10-26 06:17:28 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-26 06:17:28 (GMT) |
commit | 90a1b2859f99a4b07da6c46b99759444e3cefbfa (patch) | |
tree | e7ef4674c8e573906cfab0f3a3f096ac3fe4862d /Lib/test/test_cmd_line_script.py | |
parent | 3f84a19e6291db682fc9a570e7612e80e2ffbbb5 (diff) | |
download | cpython-90a1b2859f99a4b07da6c46b99759444e3cefbfa.zip cpython-90a1b2859f99a4b07da6c46b99759444e3cefbfa.tar.gz cpython-90a1b2859f99a4b07da6c46b99759444e3cefbfa.tar.bz2 |
gh-67224: Show source lines in tracebacks when using the -c option when running Python (#111200)
Diffstat (limited to 'Lib/test/test_cmd_line_script.py')
-rw-r--r-- | Lib/test/test_cmd_line_script.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py index e9405ff..48754d5 100644 --- a/Lib/test/test_cmd_line_script.py +++ b/Lib/test/test_cmd_line_script.py @@ -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: |