mirror of
https://github.com/django/django.git
synced 2026-02-09 02:49:25 +08:00
Switched setUp() to setUpTestData() where possible in Django's tests.
This commit is contained in:
committed by
Tim Graham
parent
9a7d336c38
commit
84e7a9f4a7
@@ -16,8 +16,9 @@ from .models import (
|
||||
|
||||
class GetOrCreateTests(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.lennon = Person.objects.create(
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
Person.objects.create(
|
||||
first_name='John', last_name='Lennon', birthday=date(1940, 10, 9)
|
||||
)
|
||||
|
||||
@@ -189,8 +190,9 @@ class GetOrCreateTests(TestCase):
|
||||
|
||||
class GetOrCreateTestsWithManualPKs(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.first_pk = ManualPrimaryKeyTest.objects.create(id=1, data="Original")
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
ManualPrimaryKeyTest.objects.create(id=1, data="Original")
|
||||
|
||||
def test_create_with_duplicate_primary_key(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user