diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-12-17 15:34:14 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-17 15:34:14 (GMT) |
commit | 94cf308ee231bfbfaa9ddc50b9764545a1318773 (patch) | |
tree | adc068a6567b6712226436ad399951ad888cb53c /Lib | |
parent | bdabb0737c631835b246c9823852d20331243315 (diff) | |
download | cpython-94cf308ee231bfbfaa9ddc50b9764545a1318773.zip cpython-94cf308ee231bfbfaa9ddc50b9764545a1318773.tar.gz cpython-94cf308ee231bfbfaa9ddc50b9764545a1318773.tar.bz2 |
bpo-33306: Improve SyntaxError messages for unbalanced parentheses. (GH-6516)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_fstring.py | 12 | ||||
-rw-r--r-- | Lib/test/test_site.py | 4 |
2 files changed, 10 insertions, 6 deletions
diff --git a/Lib/test/test_fstring.py b/Lib/test/test_fstring.py index 09b5ae1..fe3804b 100644 --- a/Lib/test/test_fstring.py +++ b/Lib/test/test_fstring.py @@ -1004,10 +1004,14 @@ non-important content self.assertEqual('{d[0]}'.format(d=d), 'integer') def test_invalid_expressions(self): - self.assertAllRaise(SyntaxError, 'invalid syntax', - [r"f'{a[4)}'", - r"f'{a(4]}'", - ]) + self.assertAllRaise(SyntaxError, + r"closing parenthesis '\)' does not match " + r"opening parenthesis '\[' \(<fstring>, line 1\)", + [r"f'{a[4)}'"]) + self.assertAllRaise(SyntaxError, + r"closing parenthesis '\]' does not match " + r"opening parenthesis '\(' \(<fstring>, line 1\)", + [r"f'{a(4]}'"]) def test_errors(self): # see issue 26287 diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py index f38e8d8..735651e 100644 --- a/Lib/test/test_site.py +++ b/Lib/test/test_site.py @@ -133,7 +133,7 @@ class HelperFunctionsTests(unittest.TestCase): def test_addpackage_import_bad_syntax(self): # Issue 10642 - pth_dir, pth_fn = self.make_pth("import bad)syntax\n") + pth_dir, pth_fn = self.make_pth("import bad-syntax\n") with captured_stderr() as err_out: site.addpackage(pth_dir, pth_fn, set()) self.assertRegex(err_out.getvalue(), "line 1") @@ -143,7 +143,7 @@ class HelperFunctionsTests(unittest.TestCase): # order doesn't matter. The next three could be a single check # but my regex foo isn't good enough to write it. self.assertRegex(err_out.getvalue(), 'Traceback') - self.assertRegex(err_out.getvalue(), r'import bad\)syntax') + self.assertRegex(err_out.getvalue(), r'import bad-syntax') self.assertRegex(err_out.getvalue(), 'SyntaxError') def test_addpackage_import_bad_exec(self): |