bpo-35169: Improve error messages for forbidden assignments. (GH-10342)

This commit is contained in:
Serhiy Storchaka 2018-11-20 19:27:16 +02:00 committed by GitHub
parent 6c48bf2d9e
commit 97f1efb606
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 140 additions and 96 deletions

View file

@ -73,11 +73,11 @@ class DictComprehensionTest(unittest.TestCase):
self.assertEqual(v, "Local variable")
def test_illegal_assignment(self):
with self.assertRaisesRegex(SyntaxError, "can't assign"):
with self.assertRaisesRegex(SyntaxError, "cannot assign"):
compile("{x: y for y, x in ((1, 2), (3, 4))} = 5", "<test>",
"exec")
with self.assertRaisesRegex(SyntaxError, "can't assign"):
with self.assertRaisesRegex(SyntaxError, "cannot assign"):
compile("{x: y for y, x in ((1, 2), (3, 4))} += 5", "<test>",
"exec")