summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTim Graham <timgraham@google.com>2013-05-24 13:30:37 -0400
committerTim Graham <timograham@gmail.com>2013-05-27 07:57:06 -0400
commit6f8627dd7fd482007694dd1e4a99f9e207e6d8c2 (patch)
tree61f000fd4889877afbb594b0c94397bc85772814 /tests
parent37ea9f9c03b8ec4305ac978e85db653b432b9921 (diff)
Fixed #17582 - Added message to DoesNotExist exceptions.
Thanks simon@ for the suggestion and JordanPowell for the initial patch.
Diffstat (limited to 'tests')
-rw-r--r--tests/foreign_object/tests.py5
-rw-r--r--tests/one_to_one/tests.py3
2 files changed, 7 insertions, 1 deletions
diff --git a/tests/foreign_object/tests.py b/tests/foreign_object/tests.py
index 55dd6a0f47..69636ee49b 100644
--- a/tests/foreign_object/tests.py
+++ b/tests/foreign_object/tests.py
@@ -316,6 +316,11 @@ class MultiColumnFKTests(TestCase):
list(Article.objects.filter(active_translation__abstract=None)),
[a1, a2])
+ def test_foreign_key_raises_informative_does_not_exist(self):
+ referrer = ArticleTranslation()
+ with self.assertRaisesMessage(Article.DoesNotExist, 'ArticleTranslation has no article'):
+ referrer.article
+
class FormsTests(TestCase):
# ForeignObjects should not have any form fields, currently the user needs
# to manually deal with the foreignobject relation.
diff --git a/tests/one_to_one/tests.py b/tests/one_to_one/tests.py
index 6ee78520bd..a36764b788 100644
--- a/tests/one_to_one/tests.py
+++ b/tests/one_to_one/tests.py
@@ -22,7 +22,8 @@ class OneToOneTests(TestCase):
# A Place can access its restaurant, if available.
self.assertEqual(repr(self.p1.restaurant), '<Restaurant: Demon Dogs the restaurant>')
# p2 doesn't have an associated restaurant.
- self.assertRaises(Restaurant.DoesNotExist, getattr, self.p2, 'restaurant')
+ with self.assertRaisesMessage(Restaurant.DoesNotExist, 'Place has no restaurant'):
+ self.p2.restaurant
def test_setter(self):
# Set the place using assignment notation. Because place is the primary