diff options
author | Mads Jensen <mje@inducks.org> | 2017-05-28 21:37:21 +0200 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2017-07-29 19:07:23 -0400 |
commit | a51c4de1945be2225f20fad794cfb52d8f1f9236 (patch) | |
tree | 36386b70a27cf027a8a491de319c3e59e0d3d0cd /tests/null_queries | |
parent | 38988f289f7f5708f5ea85de2d5dfe0d86b23106 (diff) | |
download | django-a51c4de1945be2225f20fad794cfb52d8f1f9236.tar.gz |
Used assertRaisesMessage() to test Django's error messages.
Diffstat (limited to 'tests/null_queries')
-rw-r--r-- | tests/null_queries/tests.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/null_queries/tests.py b/tests/null_queries/tests.py index 221bd05946..342b43f126 100644 --- a/tests/null_queries/tests.py +++ b/tests/null_queries/tests.py @@ -32,11 +32,12 @@ class NullQueriesTests(TestCase): self.assertSequenceEqual(Choice.objects.exclude(choice=None).order_by('id'), [c1, c2]) # Valid query, but fails because foo isn't a keyword - with self.assertRaises(FieldError): + msg = "Cannot resolve keyword 'foo' into field. Choices are: choice, id, poll, poll_id" + with self.assertRaisesMessage(FieldError, msg): Choice.objects.filter(foo__exact=None) # Can't use None on anything other than __exact and __iexact - with self.assertRaises(ValueError): + with self.assertRaisesMessage(ValueError, 'Cannot use None as a query value'): Choice.objects.filter(id__gt=None) # Related managers use __exact=None implicitly if the object hasn't been saved. |