mirror of https://github.com/python/cpython
bpo-46296: [Enum] add a test for missing `value` recovery (GH-30458)
In `__set_name__` there is a check for the `_value_` attribute and an attempt to add it if missing; this adds a test to cover the case for simple enums with a custom `__new__` method.
This commit is contained in:
parent
d382f7ee0b
commit
74d1663580
|
@ -1022,6 +1022,16 @@ class TestEnum(unittest.TestCase):
|
|||
class Huh(MyStr, MyInt, Enum):
|
||||
One = 1
|
||||
|
||||
def test_value_auto_assign(self):
|
||||
class Some(Enum):
|
||||
def __new__(cls, val):
|
||||
return object.__new__(cls)
|
||||
x = 1
|
||||
y = 2
|
||||
|
||||
self.assertEqual(Some.x.value, 1)
|
||||
self.assertEqual(Some.y.value, 2)
|
||||
|
||||
def test_hash(self):
|
||||
Season = self.Season
|
||||
dates = {}
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Add a test case for :mod:`enum`
|
||||
with ``_use_args_ == True`` and ``_member_type_ == object``.
|
Loading…
Reference in New Issue