summaryrefslogtreecommitdiff
path: root/Lib/test/support/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/support/__init__.py')
-rw-r--r--Lib/test/support/__init__.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index 698f503c59..d0d126a3a0 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -1041,9 +1041,16 @@ def make_bad_fd():
file.close()
unlink(TESTFN)
-def check_syntax_error(testcase, statement):
- testcase.assertRaises(SyntaxError, compile, statement,
- '<test string>', 'exec')
+def check_syntax_error(testcase, statement, *, lineno=None, offset=None):
+ with testcase.assertRaises(SyntaxError) as cm:
+ compile(statement, '<test string>', 'exec')
+ err = cm.exception
+ testcase.assertIsNotNone(err.lineno)
+ if lineno is not None:
+ testcase.assertEqual(err.lineno, lineno)
+ testcase.assertIsNotNone(err.offset)
+ if offset is not None:
+ testcase.assertEqual(err.offset, offset)
def open_urlresource(url, *args, **kw):
import urllib.request, urllib.parse