Given a little hierarchy of classes with some multi-inheritances and/or mixins (however you may call it).
I have a detailed test case (unittest.TestCase) for each individual base class and mixins.
How can I reuse those test cases for classes derived from the Base classes and mixins? I feel, that testing/asserting the derived class inherits from certain base classes isn't sufficient to ensure that it inherits the specific behavior of the base class(es).
I'd like to write something like:
class Base(object): # provides certain behavior class Derived(Base, Mixin): # does some additional stuff compared to Base and Mixin class BaseTest(unittest.TestCase): # tests on Base's behavior class DerivedTest(unittest.TestCase): def setUp(self): self.default = Derived() def test_has_behavior_of_base(self): # instead of self.assertIsInstance(self.default, Base) self.assertIsInstance(self.default, Mixin) # write self.assertPasses(BaseTest, Derived) Is there a pythonic way of achieving this with Pythons unittest module and a maybe a little help of the nose package?