python - Django: Keeping setUpTestData DRY -


i've been enjoying convenience of setuptestdata , --keepdb in django 1.8!

however, running issue keeping data consistent across multiple test files. i'd have setuptestdata classmethod in 1 location, , have each of test files reference it, don't have copy/paste changes each individual test file.

i'm little confused how go this, regards classmethod seems prevent me importing setuptestdata function file. can me? ahead!

current test file

from django.test import testcase models import specificmodel   class testdata(testcase):      @classmethod     def setuptestdata(cls):         cls.test_item = specificmodel.objects.create(data="some data") 

setupdata file

??? 

can inherit testdata class declares method?

base_tests.py

from django.test import testcase models import specificmodel   class testdata(testcase):      @classmethod     def setuptestdata(cls):         cls.test_item = specificmodel.objects.create(data="some data") 

specific_tests.py

from .base_tests import testdata  class subclassoftestdata(testdata):     # inherits `setuptestdata`     pass 

Comments