lundi 20 novembre 2017

Are Django test fixtures loaded multiple times?

In my tests, I have a Django super class with the sole purpose of setting up data and defining some utility methods used in the tests. It also has the fixtures used in the different TestCase subclasses.

class MasterTest(django.test.TestCase):
    fixtures = ['appname/fixtures/fixture1.json', 'appname/fixtures/fixture2.json']

class TestCase1(MasterTest):
    pass

class TestCase2(MasterTest):
    pass

My questions is whether when running TestCase1, TestCase2 and others, the fixtures defined by MasterTest will be run multiple times (one for each case) or only one, since they are defined in the super class.

If they are loaded every single time, is there a way to load fixtures only once?

Aucun commentaire:

Enregistrer un commentaire