I want to run all the test methods inherited from another class. Is there a way to do so? For example, for the following code, I want pytest
to test all the test methods of TestTwo
and TestTwelve
inherited from Test
.
class Test:
def __init__(self, n):
self.n = n
def test_even(self):
assert self.n % 2 == 0
def test_not_big(self):
assert self.n < 100
class TestTwo(Test):
def __init__(self):
super(TestTwo, self).__init__(2)
class TestTwelve(Test):
def __init__(self):
super(TestTwelve, self).__init__(12)
However, pytest
complains the existence of a __init__
constructor. I want a way to circumvent this.
The overall goal is to make my tests more modular so that I can test similar problems on multiple classes.