I would like to call the same methods on all mixins of my class. Here are two variants:
class MixinA(object):
def get_id(self):
return "A"
class MixinB(object):
def get_id(self):
return "B"
class Base(object):
def get_id(self):
for base_class in inspect.getmro(self.__class__):
return ",".join(base_class.get_id())
class Instance(MixinA, MixinB, Base):
pass
class MyTestCase(unittest.TestCase):
def test_multiple_mixin_methods(self):
"""
Sadly, we cannot call all mixin methods.
:return:
"""
ids = set(Instance().get_id())
print(ids)
assert ids == {"A", "B"}
Sadly, this fails. I only get 'A' back. I would like a list containing 'A' and 'B', order does not matter.
Anything I am doing wrong here?
Many thanks