3👍
setUpTestData
is called is once for TestCase.
In case databases does not support transactions, setUpTestData will be called before each test run.
Change your setUpClass
and don’t call setUpTestData
directly. Try to user super()
@classmethod
def setUpClass(cls):
cls.add_allowed_test_domain()
super(TenantTestCase, cls).setUpClass()
Ref:
https://docs.djangoproject.com/en/1.11/topics/testing/tools/#testcase
Note that if the tests are run on a database with no transaction support (for instance, MySQL with the MyISAM engine), setUpTestData() will be called before each test, negating the speed benefits.
Source:stackexchange.com