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/nested_foreign_keys | |
parent | 9a7d336c3866c5226ed11868be0234c7e2fa47fa (diff) | |
download | django-84e7a9f4a7bb3cad2bffae97baaae99de152c451.tar.gz |
Switched setUp() to setUpTestData() where possible in Django's tests.
Diffstat (limited to 'tests/nested_foreign_keys')
-rw-r--r-- | tests/nested_foreign_keys/tests.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tests/nested_foreign_keys/tests.py b/tests/nested_foreign_keys/tests.py index 098023d23a..08a19504e4 100644 --- a/tests/nested_foreign_keys/tests.py +++ b/tests/nested_foreign_keys/tests.py @@ -25,9 +25,10 @@ from .models import ( # relation such as introduced by one-to-one relations (through multi-table # inheritance). class NestedForeignKeysTests(TestCase): - def setUp(self): - self.director = Person.objects.create(name='Terry Gilliam / Terry Jones') - self.movie = Movie.objects.create(title='Monty Python and the Holy Grail', director=self.director) + @classmethod + def setUpTestData(cls): + cls.director = Person.objects.create(name='Terry Gilliam / Terry Jones') + cls.movie = Movie.objects.create(title='Monty Python and the Holy Grail', director=cls.director) # This test failed in #16715 because in some cases INNER JOIN was selected # for the second foreign key relation instead of LEFT OUTER JOIN. @@ -124,9 +125,10 @@ class NestedForeignKeysTests(TestCase): # nesting as we now use 4 models instead of 3 (and thus 3 relations). This # checks if promotion of join types works for deeper nesting too. class DeeplyNestedForeignKeysTests(TestCase): - def setUp(self): - self.director = Person.objects.create(name='Terry Gilliam / Terry Jones') - self.movie = Movie.objects.create(title='Monty Python and the Holy Grail', director=self.director) + @classmethod + def setUpTestData(cls): + cls.director = Person.objects.create(name='Terry Gilliam / Terry Jones') + cls.movie = Movie.objects.create(title='Monty Python and the Holy Grail', director=cls.director) def test_inheritance(self): Event.objects.create() |