Skip to content

Instantly share code, notes, and snippets.

@tarunama
Created July 4, 2016 12:15
Show Gist options
  • Save tarunama/36f1a108d5066312cc05f397f5b7dd6f to your computer and use it in GitHub Desktop.
Save tarunama/36f1a108d5066312cc05f397f5b7dd6f to your computer and use it in GitHub Desktop.
Djangoでテストデータを作成するときはsetUpTestDataを使う ref: http://qiita.com/tarunama/items/1dfb22650576f878f649
from test.common_data import UserFactory
class Test(TestCase):
@classmethod
def setUpTestData(cls):
cls.user = UserFactory.create()
def test_1(self):
print(self.user.pk) # 1
def test_2(self):
print(self.user.pk) # 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment