mirror of
https://github.com/python/cpython.git
synced 2025-10-21 14:12:27 +00:00
gh-115821: [Enum] better error message for calling super().__new__() (GH-116063)
docs now state to not call super().__new__ if super().__new__ is called, a better error message is now used
This commit is contained in:
parent
4d1d35b906
commit
3ea78fd5bc
4 changed files with 22 additions and 1 deletions
|
@ -447,7 +447,7 @@ class _EnumTests:
|
|||
def test_bad_new_super(self):
|
||||
with self.assertRaisesRegex(
|
||||
TypeError,
|
||||
'has no members defined',
|
||||
'do not use .super...__new__;',
|
||||
):
|
||||
class BadSuper(self.enum_type):
|
||||
def __new__(cls, value):
|
||||
|
@ -3409,6 +3409,17 @@ class TestSpecial(unittest.TestCase):
|
|||
self.assertIs(Types(2), Types.NetList)
|
||||
self.assertIs(Types('nl'), Types.NetList)
|
||||
|
||||
def test_no_members(self):
|
||||
with self.assertRaisesRegex(
|
||||
TypeError,
|
||||
'has no members',
|
||||
):
|
||||
Enum(7)
|
||||
with self.assertRaisesRegex(
|
||||
TypeError,
|
||||
'has no members',
|
||||
):
|
||||
Flag(7)
|
||||
|
||||
class TestOrder(unittest.TestCase):
|
||||
"test usage of the `_order_` attribute"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue