mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
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:
parent
0e1c2f3ef8
commit
4d6c0c0cce
2 changed files with 48 additions and 23 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue