summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_enum.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_enum.py')
-rw-r--r--Lib/test/test_enum.py26
1 files changed, 21 insertions, 5 deletions
diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py
index 87d7c72..69fba9a 100644
--- a/Lib/test/test_enum.py
+++ b/Lib/test/test_enum.py
@@ -2693,12 +2693,15 @@ class TestSpecial(unittest.TestCase):
@dataclass
class Foo:
__qualname__ = 'Foo'
- a: int = 0
+ a: int
class Entries(Foo, Enum):
- ENTRY1 = Foo(1)
+ ENTRY1 = 1
+ self.assertTrue(isinstance(Entries.ENTRY1, Foo))
+ self.assertTrue(Entries._member_type_ is Foo, Entries._member_type_)
+ self.assertTrue(Entries.ENTRY1.value == Foo(1), Entries.ENTRY1.value)
self.assertEqual(repr(Entries.ENTRY1), '<Entries.ENTRY1: Foo(a=1)>')
- def test_repr_with_non_data_type_mixin(self):
+ def test_repr_with_init_data_type_mixin(self):
# non-data_type is a mixin that doesn't define __new__
class Foo:
def __init__(self, a):
@@ -2706,10 +2709,23 @@ class TestSpecial(unittest.TestCase):
def __repr__(self):
return f'Foo(a={self.a!r})'
class Entries(Foo, Enum):
- ENTRY1 = Foo(1)
-
+ ENTRY1 = 1
+ #
self.assertEqual(repr(Entries.ENTRY1), '<Entries.ENTRY1: Foo(a=1)>')
+ def test_repr_and_str_with_non_data_type_mixin(self):
+ # non-data_type is a mixin that doesn't define __new__
+ class Foo:
+ def __repr__(self):
+ return 'Foo'
+ def __str__(self):
+ return 'ooF'
+ class Entries(Foo, Enum):
+ ENTRY1 = 1
+ #
+ self.assertEqual(repr(Entries.ENTRY1), 'Foo')
+ self.assertEqual(str(Entries.ENTRY1), 'ooF')
+
def test_value_backup_assign(self):
# check that enum will add missing values when custom __new__ does not
class Some(Enum):