As can be seen in the following example, I've defined a BaseClass
for all tests, each test case class inherits the base class.
Both classes needs to perform a one time initialization, when test_vehicles.py
is executed, I need to make sure that setUpClass
of the base class is invoked as well, not sure how to achieve that where @classmethod
is in play.
# base.py
import unittest
class BaseClass(unittest.TestCase):
@classmethod
def setUpClass(cls):
# initialize stuff
cls.app = app
# test_vehicles.py
class VehiclesTestCase(BaseClass):
@classmethod
def setUpClass(cls):
# initialize stuff
cls.vehicle_id = '123'
def test_get_vehicle(self):
resp = self.app.get(self.vehicle_id)
self.assertEqual(resp, True)
if __name__ == '__main__':
unittest.main()