diff options
author | Nice Zombies <nineteendo19d0@gmail.com> | 2024-12-11 19:32:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-11 19:32:54 +0100 |
commit | e8f4e272cc828f2b79fa17fc6b9786bdddab7ce4 (patch) | |
tree | 9e4e54634fbb134574484edf80f2e6838b6c4d19 /Lib/test/test_exceptions.py | |
parent | bc262de06b10a2d119c28bac75060bf00301697a (diff) | |
download | cpython-e8f4e272cc828f2b79fa17fc6b9786bdddab7ce4.tar.gz cpython-e8f4e272cc828f2b79fa17fc6b9786bdddab7ce4.zip |
gh-111609: Test `end_offset` in SyntaxError subclass (#127830)
Test `end_offset` in SyntaxError subclass
Diffstat (limited to 'Lib/test/test_exceptions.py')
-rw-r--r-- | Lib/test/test_exceptions.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index 5beeac3adfc..6ccfa9575f8 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -2274,6 +2274,21 @@ class SyntaxErrorTests(unittest.TestCase): self.assertIn(expected, err.getvalue()) the_exception = exc + def test_subclass(self): + class MySyntaxError(SyntaxError): + pass + + try: + raise MySyntaxError("bad bad", ("bad.py", 1, 2, "abcdefg", 1, 7)) + except SyntaxError as exc: + with support.captured_stderr() as err: + sys.__excepthook__(*sys.exc_info()) + self.assertIn(""" + File "bad.py", line 1 + abcdefg + ^^^^^ +""", err.getvalue()) + def test_encodings(self): self.addCleanup(unlink, TESTFN) source = ( |