Skip to content

Commit

Permalink
Removed hardcoding from get_earliest_or_latest tests' tearDown().
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisfreitag authored and timgraham committed Sep 5, 2017
1 parent 2ef4b47 commit 6639464
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/get_earliest_or_latest/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
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.
Expand Down

0 comments on commit 6639464

Please sign in to comment.