mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.11] gh-106300: Improve assertRaises(Exception) usages in tests (GH-106302). (GH-106545)
(cherry picked from commit 6e6a4cd523)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
parent
1931c2a438
commit
6cd08a566f
7 changed files with 20 additions and 12 deletions
|
|
@ -448,15 +448,16 @@ class S(metaclass=abc_ABCMeta):
|
|||
|
||||
# Also check that issubclass() propagates exceptions raised by
|
||||
# __subclasses__.
|
||||
class CustomError(Exception): ...
|
||||
exc_msg = "exception from __subclasses__"
|
||||
|
||||
def raise_exc():
|
||||
raise Exception(exc_msg)
|
||||
raise CustomError(exc_msg)
|
||||
|
||||
class S(metaclass=abc_ABCMeta):
|
||||
__subclasses__ = raise_exc
|
||||
|
||||
with self.assertRaisesRegex(Exception, exc_msg):
|
||||
with self.assertRaisesRegex(CustomError, exc_msg):
|
||||
issubclass(int, S)
|
||||
|
||||
def test_subclasshook(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue