Skip to content

Commit

Permalink
gh-111609: Test end_offset in SyntaxError subclass (#127830)
Browse files Browse the repository at this point in the history
Test `end_offset` in SyntaxError subclass
  • Loading branch information
nineteendo authored Dec 11, 2024
1 parent bc262de commit e8f4e27
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 @@ -2274,6 +2274,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 e8f4e27

Please sign in to comment.