bpo-45871: Refactor except matcher validation into a separate function so that it can be reused. Add missing unit test. (GH-29711)

This commit is contained in:
Irit Katriel 2021-11-22 16:56:23 +00:00 committed by GitHub
parent 0e1c2f3ef8
commit 4d6c0c0cce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 23 deletions

View file

@ -2401,6 +2401,21 @@ class SyntaxErrorTests(unittest.TestCase):
self.assertRaises(TypeError, SyntaxError, "bad bad", args)
class TestInvalidExceptionMatcher(unittest.TestCase):
def test_except_star_invalid_exception_type(self):
with self.assertRaises(TypeError):
try:
raise ValueError
except 42:
pass
with self.assertRaises(TypeError):
try:
raise ValueError
except (ValueError, 42):
pass
class PEP626Tests(unittest.TestCase):
def lineno_after_raise(self, f, *expected):