From a51c4de1945be2225f20fad794cfb52d8f1f9236 Mon Sep 17 00:00:00 2001 From: Mads Jensen Date: Sun, 28 May 2017 21:37:21 +0200 Subject: Used assertRaisesMessage() to test Django's error messages. --- tests/custom_columns/tests.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tests/custom_columns') diff --git a/tests/custom_columns/tests.py b/tests/custom_columns/tests.py index 2d7044b8de..f5dfd9c0cd 100644 --- a/tests/custom_columns/tests.py +++ b/tests/custom_columns/tests.py @@ -37,7 +37,11 @@ class CustomColumnsTests(TestCase): ) def test_field_error(self): - with self.assertRaises(FieldError): + msg = ( + "Cannot resolve keyword 'firstname' into field. Choices are: " + "Author_ID, article, first_name, last_name, primary_set" + ) + with self.assertRaisesMessage(FieldError, msg): Author.objects.filter(firstname__exact="John") def test_attribute_error(self): -- cgit v1.2.1