diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-12-11 12:44:21 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-12-11 12:44:21 (GMT) |
commit | 26817a84908b831d71dd59de432f75829a5bae33 (patch) | |
tree | 155827823d4c5c344adbae096cbbe2f634263b45 /Lib/test/test_syntax.py | |
parent | 2b27c2ddbaee778b4de128bd43359b66dcda01f8 (diff) | |
parent | 8114f21668fe9775d2542d079c6396a745f4f094 (diff) | |
download | cpython-26817a84908b831d71dd59de432f75829a5bae33.zip cpython-26817a84908b831d71dd59de432f75829a5bae33.tar.gz cpython-26817a84908b831d71dd59de432f75829a5bae33.tar.bz2 |
Issue #28512: Fixed setting the offset attribute of SyntaxError by
PyErr_SyntaxLocationEx() and PyErr_SyntaxLocationObject().
Diffstat (limited to 'Lib/test/test_syntax.py')
-rw-r--r-- | Lib/test/test_syntax.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index 6364266..dd740b4 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -548,7 +548,7 @@ from test import support class SyntaxTestCase(unittest.TestCase): def _check_error(self, code, errtext, - filename="<testcase>", mode="exec", subclass=None): + filename="<testcase>", mode="exec", subclass=None, lineno=None, offset=None): """Check that compiling code raises SyntaxError with errtext. errtest is a regular expression that must be present in the @@ -563,6 +563,11 @@ class SyntaxTestCase(unittest.TestCase): mo = re.search(errtext, str(err)) if mo is None: self.fail("SyntaxError did not contain '%r'" % (errtext,)) + self.assertEqual(err.filename, filename) + if lineno is not None: + self.assertEqual(err.lineno, lineno) + if offset is not None: + self.assertEqual(err.offset, offset) else: self.fail("compile() did not raise SyntaxError") @@ -573,7 +578,7 @@ class SyntaxTestCase(unittest.TestCase): self._check_error("del f()", "delete") def test_global_err_then_warn(self): - # Bug tickler: The SyntaxError raised for one global statement + # Bug #763201: The SyntaxError raised for one global statement # shouldn't be clobbered by a SyntaxWarning issued for a later one. source = """if 1: def error(a): |