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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user