bpo-33306: Improve SyntaxError messages for unbalanced parentheses. (GH-6516)

This commit is contained in:
Serhiy Storchaka 2018-12-17 17:34:14 +02:00 committed by GitHub
parent bdabb0737c
commit 94cf308ee2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 7 deletions

View file

@ -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