Skip to content

Commit

Permalink
pythongh-111609: Test end_offset in SyntaxError subclass (pythonGH-…
Browse files Browse the repository at this point in the history
…127830)

Test `end_offset` in SyntaxError subclass
(cherry picked from commit e8f4e27)

Co-authored-by: Nice Zombies <nineteendo19d0@gmail.com>
  • Loading branch information
nineteendo authored and miss-islington committed Feb 21, 2025
1 parent 2a978e1 commit 005bf39
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Lib/test/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2253,6 +2253,21 @@ def test_range_of_offsets(self):
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 = (
Expand Down

0 comments on commit 005bf39

Please # to comment.