I've been really enjoying the convenience of setUpTestData and --keepdb in Django 1.8!
However, I am running into an issue keeping data consistent across multiple test files. I'd like to have my setUpTestData classmethod in one location, and have each of my test files reference it, so that I don't have to copy/paste changes into each individual test file.
I'm a little confused about how to go about this, specifically with regards to the classmethod which seems to prevent me from importing my setUpTestData function from another file. Can someone help me? Thanks ahead!
Current test file
from django.test import TestCase
from models import SpecificModel
class TestData(TestCase):
@classmethod
def setUpTestData(cls):
cls.test_item = SpecificModel.objects.create(data="some data")
SetupData file
???
self
as an argument and notcls
. Thanks for pointing me in the right direction! – Lithology