summaryrefslogtreecommitdiff
path: root/Lib/test/test_syntax.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-12-11 14:43:18 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2016-12-11 14:43:18 +0200
commit8114f21668fe9775d2542d079c6396a745f4f094 (patch)
tree62ef9087e76229ea0fd18d0a1052abd79c9ae2f3 /Lib/test/test_syntax.py
parent0a7b8596c075b3d69e2fae3c71746415ba3bad39 (diff)
parent8b58339eb2939da4df822f7ea457b44e120fad45 (diff)
downloadcpython-git-8114f21668fe9775d2542d079c6396a745f4f094.tar.gz
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.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index 80e36fd46e..7f7e6dafcf 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -544,7 +544,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
@@ -559,6 +559,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")
@@ -569,7 +574,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):