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/admin_ordering | |
parent | 9a7d336c3866c5226ed11868be0234c7e2fa47fa (diff) | |
download | django-84e7a9f4a7bb3cad2bffae97baaae99de152c451.tar.gz |
Switched setUp() to setUpTestData() where possible in Django's tests.
Diffstat (limited to 'tests/admin_ordering')
-rw-r--r-- | tests/admin_ordering/tests.py | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/tests/admin_ordering/tests.py b/tests/admin_ordering/tests.py index 8de35fa32c..026c76fe23 100644 --- a/tests/admin_ordering/tests.py +++ b/tests/admin_ordering/tests.py @@ -35,14 +35,17 @@ class TestAdminOrdering(TestCase): class. """ - def setUp(self): - self.request_factory = RequestFactory() + @classmethod + def setUpTestData(cls): Band.objects.bulk_create([ Band(name='Aerosmith', bio='', rank=3), Band(name='Radiohead', bio='', rank=1), Band(name='Van Halen', bio='', rank=2), ]) + def setUp(self): + self.request_factory = RequestFactory() + def test_default_ordering(self): """ The default ordering should be by name, as specified in the inner Meta @@ -92,12 +95,13 @@ class TestInlineModelAdminOrdering(TestCase): define in InlineModelAdmin. """ - def setUp(self): - self.band = Band.objects.create(name='Aerosmith', bio='', rank=3) + @classmethod + def setUpTestData(cls): + cls.band = Band.objects.create(name='Aerosmith', bio='', rank=3) Song.objects.bulk_create([ - Song(band=self.band, name='Pink', duration=235), - Song(band=self.band, name='Dude (Looks Like a Lady)', duration=264), - Song(band=self.band, name='Jaded', duration=214), + Song(band=cls.band, name='Pink', duration=235), + Song(band=cls.band, name='Dude (Looks Like a Lady)', duration=264), + Song(band=cls.band, name='Jaded', duration=214), ]) def test_default_ordering(self): @@ -119,10 +123,12 @@ class TestInlineModelAdminOrdering(TestCase): class TestRelatedFieldsAdminOrdering(TestCase): - def setUp(self): - self.b1 = Band.objects.create(name='Pink Floyd', bio='', rank=1) - self.b2 = Band.objects.create(name='Foo Fighters', bio='', rank=5) + @classmethod + def setUpTestData(cls): + cls.b1 = Band.objects.create(name='Pink Floyd', bio='', rank=1) + cls.b2 = Band.objects.create(name='Foo Fighters', bio='', rank=5) + def setUp(self): # we need to register a custom ModelAdmin (instead of just using # ModelAdmin) because the field creator tries to find the ModelAdmin # for the related model |