summaryrefslogtreecommitdiff
path: root/docs/intro/tutorial05.txt
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2016-06-16 11:19:18 -0700
committerTim Graham <timograham@gmail.com>2016-06-16 14:19:18 -0400
commit4f336f66523001b009ab038b10848508fd208b3b (patch)
tree47474fb588013f1770246455ef7aa1a4163a1edb /docs/intro/tutorial05.txt
parentea34426ae789d31b036f58c8fd59ce299649e91e (diff)
Fixed #26747 -- Used more specific assertions in the Django test suite.
Diffstat (limited to 'docs/intro/tutorial05.txt')
-rw-r--r--docs/intro/tutorial05.txt10
1 files changed, 5 insertions, 5 deletions
diff --git a/docs/intro/tutorial05.txt b/docs/intro/tutorial05.txt
index bfb43358e6..f88f6686bd 100644
--- a/docs/intro/tutorial05.txt
+++ b/docs/intro/tutorial05.txt
@@ -180,7 +180,7 @@ Put the following in the ``tests.py`` file in the ``polls`` application:
"""
time = timezone.now() + datetime.timedelta(days=30)
future_question = Question(pub_date=time)
- self.assertEqual(future_question.was_published_recently(), False)
+ self.assertIs(future_question.was_published_recently(), False)
What we have done here is created a :class:`django.test.TestCase` subclass
with a method that creates a ``Question`` instance with a ``pub_date`` in the
@@ -203,8 +203,8 @@ and you'll see something like::
----------------------------------------------------------------------
Traceback (most recent call last):
File "/path/to/mysite/polls/tests.py", line 16, in test_was_published_recently_with_future_question
- self.assertEqual(future_question.was_published_recently(), False)
- AssertionError: True != False
+ self.assertIs(future_question.was_published_recently(), False)
+ AssertionError: True is not False
----------------------------------------------------------------------
Ran 1 test in 0.001s
@@ -285,7 +285,7 @@ more comprehensively:
"""
time = timezone.now() - datetime.timedelta(days=30)
old_question = Question(pub_date=time)
- self.assertEqual(old_question.was_published_recently(), False)
+ self.assertIs(old_question.was_published_recently(), False)
def test_was_published_recently_with_recent_question(self):
"""
@@ -294,7 +294,7 @@ more comprehensively:
"""
time = timezone.now() - datetime.timedelta(hours=1)
recent_question = Question(pub_date=time)
- self.assertEqual(recent_question.was_published_recently(), True)
+ self.assertIs(recent_question.was_published_recently(), True)
And now we have three tests that confirm that ``Question.was_published_recently()``
returns sensible values for past, recent, and future questions.