These are chat archives for django/django

25th
Oct 2017
kpagcha
@kpagcha
Oct 25 2017 07:22

I have these TestCases:

class ComponentTest(TestCase):
    fixtures = ['data.json']

    @classmethod
    def setUpTestData(cls):
        # ...

class Component1Test(ComponentTest):
    # ...

class Component2Test(ComponentTest):
    # ...

When running test, fixture load and setUpTestData is run multiple times, both for Component1Test and Component2Test separately. Is there any way I could make it run just once?

matrixbot
@matrixbot
Oct 25 2017 10:49
@bignose:matrix.org kpagcha (Gitter): the unittest model is designed to build a test suite of independent test cases. That is, the set up tends to be done each time a test case starts.
@bignose:matrix.org kpagcha (Gitter): If you want a bunch of setup that persists between test cases, they're not really independent and you won't be testing whether things work correctly in isolation.
@bignose:matrix.org kpagcha (Gitter): Maybe you don't want unit tests?