summaryrefslogtreecommitdiff
path: root/tests/get_earliest_or_latest
diff options
context:
space:
mode:
authorFrançois Freitag <mail@franek.fr>2017-06-21 13:21:27 -0700
committerTim Graham <timograham@gmail.com>2017-09-05 10:04:22 -0400
commit663946463db4c0f00a842881112568881d2dd0cd (patch)
tree31f9168ab7cdb0b1b3880f64fba7b93b1509777a /tests/get_earliest_or_latest
parent2ef4b4795e29be8c33a6de9cc0c05b59025d13a5 (diff)
downloaddjango-663946463db4c0f00a842881112568881d2dd0cd.tar.gz
Removed hardcoding from get_earliest_or_latest tests' tearDown().
Diffstat (limited to 'tests/get_earliest_or_latest')
-rw-r--r--tests/get_earliest_or_latest/tests.py9
1 files 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.