diff options
| author | Sergey B Kirpichev <skirpichev@gmail.com> | 2024-08-19 19:01:58 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-19 19:01:58 (GMT) |
| commit | c8f4069ab1602a1f67239fef0e11cc3e72c0045d (patch) | |
| tree | 958e6704cd0102ea848a511fec9f7d8f50cc9dd7 /Lib/test/test_pyrepl/test_interact.py | |
| parent | 21399a096302ea577efd9a12c2f08b4458d095bd (diff) | |
| download | cpython-c8f4069ab1602a1f67239fef0e11cc3e72c0045d.zip cpython-c8f4069ab1602a1f67239fef0e11cc3e72c0045d.tar.gz cpython-c8f4069ab1602a1f67239fef0e11cc3e72c0045d.tar.bz2 | |
[3.13] gh-121804: Always show error location for SyntaxError's in new repl (GH-121886) (#123148)
(cherry picked from commit 354d55eb1fa40f272419aa6459ee5d2c4804c8ea)
Diffstat (limited to 'Lib/test/test_pyrepl/test_interact.py')
| -rw-r--r-- | Lib/test/test_pyrepl/test_interact.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_pyrepl/test_interact.py b/Lib/test/test_pyrepl/test_interact.py index 538dfd3..e71ab41 100644 --- a/Lib/test/test_pyrepl/test_interact.py +++ b/Lib/test/test_pyrepl/test_interact.py @@ -88,6 +88,20 @@ class TestSimpleInteract(unittest.TestCase): self.assertFalse(result) self.assertIn('SyntaxError', f.getvalue()) + @force_not_colorized + def test_runsource_show_syntax_error_location(self): + console = InteractiveColoredConsole() + source = "def f(x, x): ..." + f = io.StringIO() + with contextlib.redirect_stderr(f): + result = console.runsource(source) + self.assertFalse(result) + r = """ + def f(x, x): ... + ^ +SyntaxError: duplicate argument 'x' in function definition""" + self.assertIn(r, f.getvalue()) + def test_runsource_shows_syntax_error_for_failed_compilation(self): console = InteractiveColoredConsole() source = "print('Hello, world!'" |
