summaryrefslogtreecommitdiff
path: root/tests/many_to_one_null
diff options
context:
space:
mode:
authorHasan <hasan.r67@gmail.com>2016-01-17 14:56:39 +0330
committerTim Graham <timograham@gmail.com>2016-01-29 12:32:18 -0500
commit3d0dcd7f5af378d3ab6adb303b913e6c7b2e0ee5 (patch)
tree0d1074cc65a72096e44a4165611fddfc5b7ef7fb /tests/many_to_one_null
parent575706331bec4bf58ce36a9540c4c61fca49025b (diff)
downloaddjango-3d0dcd7f5af378d3ab6adb303b913e6c7b2e0ee5.tar.gz
Refs #26022 -- Used context manager version of assertRaises in tests.
Diffstat (limited to 'tests/many_to_one_null')
-rw-r--r--tests/many_to_one_null/tests.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/many_to_one_null/tests.py b/tests/many_to_one_null/tests.py
index 91c2e13cd7..1a3785bd33 100644
--- a/tests/many_to_one_null/tests.py
+++ b/tests/many_to_one_null/tests.py
@@ -44,7 +44,8 @@ class ManyToOneNullTests(TestCase):
self.assertEqual(self.a3.reporter, None)
# Need to reget a3 to refresh the cache
a3 = Article.objects.get(pk=self.a3.pk)
- self.assertRaises(AttributeError, getattr, a3.reporter, 'id')
+ 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)
@@ -71,7 +72,8 @@ class ManyToOneNullTests(TestCase):
def test_remove_from_wrong_set(self):
self.assertQuerysetEqual(self.r2.article_set.all(), ['<Article: Fourth>'])
# Try to remove a4 from a set it does not belong to
- self.assertRaises(Reporter.DoesNotExist, self.r.article_set.remove, self.a4)
+ with self.assertRaises(Reporter.DoesNotExist):
+ self.r.article_set.remove(self.a4)
self.assertQuerysetEqual(self.r2.article_set.all(), ['<Article: Fourth>'])
def test_set(self):