mirror of
https://github.com/python/cpython.git
synced 2025-08-26 19:55:24 +00:00
bpo-34909: keep searching mixins until base class is found (GH-9737)
This commit is contained in:
parent
92878829c3
commit
cd45385ffa
2 changed files with 22 additions and 3 deletions
|
@ -1842,6 +1842,27 @@ class TestEnum(unittest.TestCase):
|
|||
self.assertEqual(ConfusedColor.RED.social(), "what's up?")
|
||||
self.assertTrue(issubclass(ReformedColor, int))
|
||||
|
||||
def test_multiple_inherited_mixin(self):
|
||||
class StrEnum(str, Enum):
|
||||
def __new__(cls, *args, **kwargs):
|
||||
for a in args:
|
||||
if not isinstance(a, str):
|
||||
raise TypeError("Enumeration '%s' (%s) is not"
|
||||
" a string" % (a, type(a).__name__))
|
||||
return str.__new__(cls, *args, **kwargs)
|
||||
@unique
|
||||
class Decision1(StrEnum):
|
||||
REVERT = "REVERT"
|
||||
REVERT_ALL = "REVERT_ALL"
|
||||
RETRY = "RETRY"
|
||||
class MyEnum(StrEnum):
|
||||
pass
|
||||
@unique
|
||||
class Decision2(MyEnum):
|
||||
REVERT = "REVERT"
|
||||
REVERT_ALL = "REVERT_ALL"
|
||||
RETRY = "RETRY"
|
||||
|
||||
|
||||
class TestOrder(unittest.TestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue