1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

[1.10.x] Fixed #26747 -- Used more specific assertions in the Django test suite.

Backport of 4f336f6652 from master
This commit is contained in:
Jon Dufresne
2016-06-16 11:19:18 -07:00
committed by Tim Graham
parent 70b7d6b4ea
commit 13d60298ea
87 changed files with 404 additions and 404 deletions

View File

@@ -39,14 +39,14 @@ class ManyToOneNullTests(TestCase):
self.assertEqual(self.r.article_set.count(), 2)
def test_created_without_related(self):
self.assertEqual(self.a3.reporter, None)
self.assertIsNone(self.a3.reporter)
# Need to reget a3 to refresh the cache
a3 = Article.objects.get(pk=self.a3.pk)
with self.assertRaises(AttributeError):
getattr(a3.reporter, 'id')
# Accessing an article's 'reporter' attribute returns None
# if the reporter is set to None.
self.assertEqual(a3.reporter, None)
self.assertIsNone(a3.reporter)
# To retrieve the articles with no reporters set, use "reporter__isnull=True".
self.assertQuerysetEqual(Article.objects.filter(reporter__isnull=True), ['<Article: Third>'])
# We can achieve the same thing by filtering for the case where the