mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
gh-111609: Test end_offset
in SyntaxError subclass (#127830)
Test `end_offset` in SyntaxError subclass
This commit is contained in:
parent
bc262de06b
commit
e8f4e272cc
1 changed files with 15 additions and 0 deletions
|
@ -2274,6 +2274,21 @@ class SyntaxErrorTests(unittest.TestCase):
|
||||||
self.assertIn(expected, err.getvalue())
|
self.assertIn(expected, err.getvalue())
|
||||||
the_exception = exc
|
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):
|
def test_encodings(self):
|
||||||
self.addCleanup(unlink, TESTFN)
|
self.addCleanup(unlink, TESTFN)
|
||||||
source = (
|
source = (
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue