From 663946463db4c0f00a842881112568881d2dd0cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Freitag?= Date: Wed, 21 Jun 2017 13:21:27 -0700 Subject: [PATCH] Removed hardcoding from get_earliest_or_latest tests' tearDown(). --- tests/get_earliest_or_latest/tests.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/get_earliest_or_latest/tests.py b/tests/get_earliest_or_latest/tests.py index eaa318663f..5b05dff487 100644 --- a/tests/get_earliest_or_latest/tests.py +++ b/tests/get_earliest_or_latest/tests.py @@ -8,10 +8,13 @@ from .models import Article, IndexErrorArticle, Person class EarliestOrLatestTests(TestCase): """Tests for the earliest() and latest() objects methods""" + @classmethod + def setUpClass(cls): + super().setUpClass() + cls._article_get_latest_by = Article._meta.get_latest_by + def tearDown(self): - """Makes sure Article has a get_latest_by""" - if not Article._meta.get_latest_by: - Article._meta.get_latest_by = 'pub_date' + Article._meta.get_latest_by = self._article_get_latest_by def test_earliest(self): # Because no Articles exist yet, earliest() raises ArticleDoesNotExist.