diff options
author | Simon Charette <charette.s@gmail.com> | 2018-11-23 20:59:38 -0500 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2018-11-27 09:35:17 -0500 |
commit | 84e7a9f4a7bb3cad2bffae97baaae99de152c451 (patch) | |
tree | c81eeb6edf47ce0abdb7551cd28a3de354dfd20f /tests/m2o_recursive | |
parent | 9a7d336c3866c5226ed11868be0234c7e2fa47fa (diff) | |
download | django-84e7a9f4a7bb3cad2bffae97baaae99de152c451.tar.gz |
Switched setUp() to setUpTestData() where possible in Django's tests.
Diffstat (limited to 'tests/m2o_recursive')
-rw-r--r-- | tests/m2o_recursive/tests.py | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/tests/m2o_recursive/tests.py b/tests/m2o_recursive/tests.py index 0f7ee9071d..309b61f260 100644 --- a/tests/m2o_recursive/tests.py +++ b/tests/m2o_recursive/tests.py @@ -5,11 +5,12 @@ from .models import Category, Person class ManyToOneRecursiveTests(TestCase): - def setUp(self): - self.r = Category(id=None, name='Root category', parent=None) - self.r.save() - self.c = Category(id=None, name='Child category', parent=self.r) - self.c.save() + @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() def test_m2o_recursive(self): self.assertQuerysetEqual(self.r.child_set.all(), @@ -22,13 +23,14 @@ class ManyToOneRecursiveTests(TestCase): class MultipleManyToOneRecursiveTests(TestCase): - def setUp(self): - self.dad = Person(full_name='John Smith Senior', mother=None, father=None) - self.dad.save() - self.mom = Person(full_name='Jane Smith', mother=None, father=None) - self.mom.save() - self.kid = Person(full_name='John Smith Junior', mother=self.mom, father=self.dad) - self.kid.save() + @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() def test_m2o_recursive2(self): self.assertEqual(self.kid.mother.id, self.mom.id) |