diff options
author | Simon Charette <charette.s@gmail.com> | 2015-11-04 11:14:22 +0100 |
---|---|---|
committer | Simon Charette <charette.s@gmail.com> | 2016-01-06 21:24:07 -0500 |
commit | 5ccb7f5f22e354ba3546071ec0351d0e9c86c229 (patch) | |
tree | 59403f449a3bd4b3d2fc912a59e24c3fcb31bbc4 /tests/m2m_through | |
parent | 7b8e4545c3521c6081db993ed2c14daa277d8dd9 (diff) | |
download | django-5ccb7f5f22e354ba3546071ec0351d0e9c86c229.tar.gz |
Used setupTestData in m2m_through tests.
Diffstat (limited to 'tests/m2m_through')
-rw-r--r-- | tests/m2m_through/tests.py | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/tests/m2m_through/tests.py b/tests/m2m_through/tests.py index 772ac1f0e9..badaeb4b87 100644 --- a/tests/m2m_through/tests.py +++ b/tests/m2m_through/tests.py @@ -13,12 +13,13 @@ from .models import ( class M2mThroughTests(TestCase): - def setUp(self): - self.bob = Person.objects.create(name='Bob') - self.jim = Person.objects.create(name='Jim') - self.jane = Person.objects.create(name='Jane') - self.rock = Group.objects.create(name='Rock') - self.roll = Group.objects.create(name='Roll') + @classmethod + def setUpTestData(cls): + cls.bob = Person.objects.create(name='Bob') + cls.jim = Person.objects.create(name='Jim') + cls.jane = Person.objects.create(name='Jane') + cls.rock = Group.objects.create(name='Rock') + cls.roll = Group.objects.create(name='Roll') def test_retrieve_intermediate_items(self): Membership.objects.create(person=self.jim, group=self.rock) @@ -432,14 +433,15 @@ class M2mThroughReferentialTests(TestCase): class M2mThroughToFieldsTests(TestCase): - def setUp(self): - self.pea = Ingredient.objects.create(iname='pea') - self.potato = Ingredient.objects.create(iname='potato') - self.tomato = Ingredient.objects.create(iname='tomato') - self.curry = Recipe.objects.create(rname='curry') - RecipeIngredient.objects.create(recipe=self.curry, ingredient=self.potato) - RecipeIngredient.objects.create(recipe=self.curry, ingredient=self.pea) - RecipeIngredient.objects.create(recipe=self.curry, ingredient=self.tomato) + @classmethod + def setUpTestData(cls): + cls.pea = Ingredient.objects.create(iname='pea') + cls.potato = Ingredient.objects.create(iname='potato') + cls.tomato = Ingredient.objects.create(iname='tomato') + cls.curry = Recipe.objects.create(rname='curry') + RecipeIngredient.objects.create(recipe=cls.curry, ingredient=cls.potato) + RecipeIngredient.objects.create(recipe=cls.curry, ingredient=cls.pea) + RecipeIngredient.objects.create(recipe=cls.curry, ingredient=cls.tomato) def test_retrieval(self): # Forward retrieval |