Removed hardcoding from get_earliest_or_latest tests' tearDown().

This commit is contained in:
François Freitag 2017-06-21 13:21:27 -07:00 committed by Tim Graham
parent 2ef4b4795e
commit 663946463d
1 changed files with 6 additions and 3 deletions

View File

@ -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.