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/foreign_object | |
| parent | 38988f289f7f5708f5ea85de2d5dfe0d86b23106 (diff) | |
Used assertRaisesMessage() to test Django's error messages.
Diffstat (limited to 'tests/foreign_object')
| -rw-r--r-- | tests/foreign_object/tests.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/foreign_object/tests.py b/tests/foreign_object/tests.py index e74732ab72..59d4357802 100644 --- a/tests/foreign_object/tests.py +++ b/tests/foreign_object/tests.py @@ -368,7 +368,12 @@ class MultiColumnFKTests(TestCase): ArticleTag.objects.create(article=a1, name="foo") self.assertEqual(Article.objects.filter(tag__name="foo").count(), 1) self.assertEqual(Article.objects.filter(tag__name="bar").count(), 0) - with self.assertRaises(FieldError): + msg = ( + "Cannot resolve keyword 'tags' into field. Choices are: " + "active_translation, active_translation_q, articletranslation, " + "id, idea_things, newsarticle, pub_date, tag" + ) + with self.assertRaisesMessage(FieldError, msg): Article.objects.filter(tags__name="foo") def test_many_to_many_related_query_name(self): @@ -377,7 +382,12 @@ class MultiColumnFKTests(TestCase): a1.ideas.add(i1) self.assertEqual(Article.objects.filter(idea_things__name="idea1").count(), 1) self.assertEqual(Article.objects.filter(idea_things__name="idea2").count(), 0) - with self.assertRaises(FieldError): + msg = ( + "Cannot resolve keyword 'ideas' into field. Choices are: " + "active_translation, active_translation_q, articletranslation, " + "id, idea_things, newsarticle, pub_date, tag" + ) + with self.assertRaisesMessage(FieldError, msg): Article.objects.filter(ideas__name="idea1") @translation.override('fi') |
