mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Adjusted code style of a few test data setup methods.
Thanks Mariusz for suggesting it.
This commit is contained in:
committed by
Tim Graham
parent
84e7a9f4a7
commit
7f63b894c0
@@ -7,10 +7,8 @@ class ManyToOneRecursiveTests(TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
cls.r = Category(id=None, name='Root category', parent=None)
|
||||
cls.r.save()
|
||||
cls.c = Category(id=None, name='Child category', parent=cls.r)
|
||||
cls.c.save()
|
||||
cls.r = Category.objects.create(id=None, name='Root category', parent=None)
|
||||
cls.c = Category.objects.create(id=None, name='Child category', parent=cls.r)
|
||||
|
||||
def test_m2o_recursive(self):
|
||||
self.assertQuerysetEqual(self.r.child_set.all(),
|
||||
@@ -25,12 +23,9 @@ class MultipleManyToOneRecursiveTests(TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
cls.dad = Person(full_name='John Smith Senior', mother=None, father=None)
|
||||
cls.dad.save()
|
||||
cls.mom = Person(full_name='Jane Smith', mother=None, father=None)
|
||||
cls.mom.save()
|
||||
cls.kid = Person(full_name='John Smith Junior', mother=cls.mom, father=cls.dad)
|
||||
cls.kid.save()
|
||||
cls.dad = Person.objects.create(full_name='John Smith Senior', mother=None, father=None)
|
||||
cls.mom = Person.objects.create(full_name='Jane Smith', mother=None, father=None)
|
||||
cls.kid = Person.objects.create(full_name='John Smith Junior', mother=cls.mom, father=cls.dad)
|
||||
|
||||
def test_m2o_recursive2(self):
|
||||
self.assertEqual(self.kid.mother.id, self.mom.id)
|
||||
|
||||
Reference in New Issue
Block a user