From 84e7a9f4a7bb3cad2bffae97baaae99de152c451 Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Fri, 23 Nov 2018 20:59:38 -0500 Subject: Switched setUp() to setUpTestData() where possible in Django's tests. --- tests/custom_columns/tests.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'tests/custom_columns/tests.py') diff --git a/tests/custom_columns/tests.py b/tests/custom_columns/tests.py index f5dfd9c0cd..874b024050 100644 --- a/tests/custom_columns/tests.py +++ b/tests/custom_columns/tests.py @@ -6,13 +6,14 @@ from .models import Article, Author class CustomColumnsTests(TestCase): - def setUp(self): - self.a1 = Author.objects.create(first_name="John", last_name="Smith") - self.a2 = Author.objects.create(first_name="Peter", last_name="Jones") - self.authors = [self.a1, self.a2] - - self.article = Article.objects.create(headline="Django lets you build Web apps easily", primary_author=self.a1) - self.article.authors.set(self.authors) + @classmethod + def setUpTestData(cls): + cls.a1 = Author.objects.create(first_name="John", last_name="Smith") + cls.a2 = Author.objects.create(first_name="Peter", last_name="Jones") + cls.authors = [cls.a1, cls.a2] + + cls.article = Article.objects.create(headline="Django lets you build Web apps easily", primary_author=cls.a1) + cls.article.authors.set(cls.authors) def test_query_all_available_authors(self): self.assertQuerysetEqual( -- cgit v1.2.1