summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_enum.py
diff options
context:
space:
mode:
authorEthan Furman <ethan@stoneleaf.us>2020-12-07 08:17:31 (GMT)
committerGitHub <noreply@github.com>2020-12-07 08:17:31 (GMT)
commitc266736ec1f9ebef38b134ceb4832df015711b38 (patch)
tree11828a60f85d516791d4d3309d6217a7d047405d /Lib/test/test_enum.py
parent212337369a64aa96d8b370f39b70113078ad0020 (diff)
downloadcpython-c266736ec1f9ebef38b134ceb4832df015711b38.zip
cpython-c266736ec1f9ebef38b134ceb4832df015711b38.tar.gz
cpython-c266736ec1f9ebef38b134ceb4832df015711b38.tar.bz2
bpo-41889: [Enum] fix multiple-inheritance regression (GH-22487)
Diffstat (limited to 'Lib/test/test_enum.py')
-rw-r--r--Lib/test/test_enum.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py
index 3431040..d1dd2e7 100644
--- a/Lib/test/test_enum.py
+++ b/Lib/test/test_enum.py
@@ -2021,6 +2021,32 @@ class TestEnum(unittest.TestCase):
REVERT_ALL = "REVERT_ALL"
RETRY = "RETRY"
+ def test_multiple_mixin_inherited(self):
+ class MyInt(int):
+ def __new__(cls, value):
+ return super().__new__(cls, value)
+
+ class HexMixin:
+ def __repr__(self):
+ return hex(self)
+
+ class MyIntEnum(HexMixin, MyInt, enum.Enum):
+ pass
+
+ class Foo(MyIntEnum):
+ TEST = 1
+ self.assertTrue(isinstance(Foo.TEST, MyInt))
+ self.assertEqual(repr(Foo.TEST), "0x1")
+
+ class Fee(MyIntEnum):
+ TEST = 1
+ def __new__(cls, value):
+ value += 1
+ member = int.__new__(cls, value)
+ member._value_ = value
+ return member
+ self.assertEqual(Fee.TEST, 2)
+
def test_empty_globals(self):
# bpo-35717: sys._getframe(2).f_globals['__name__'] fails with KeyError
# when using compile and exec because f_globals is empty