I have a dedicated test class for each different component I need to test in a particular module. All these tests revolve around the same object/context so it could be an improvement in performance if the corresponding objects weren't created and inserted in the test database and then deleted for every single test class:
class ContextTest(TestCase):
fixtures = [...]
@classmethod
def setUpTestData(cls):
pass
# executes setUpTestData
class Component1Test(ContextTest):
pass
# executes setUpTestData again
class Component2Test(ContextTest):
pass
Is there any way I can ensure that setUpTestData
is run only once, while keeping my tests under different classes for clarity's sake?
Aucun commentaire:
Enregistrer un commentaire