diff options
Diffstat (limited to 'tests/custom_columns/tests.py')
| -rw-r--r-- | tests/custom_columns/tests.py | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/tests/custom_columns/tests.py b/tests/custom_columns/tests.py index 2b5526453f..7102e4fdbe 100644 --- a/tests/custom_columns/tests.py +++ b/tests/custom_columns/tests.py @@ -91,31 +91,22 @@ class CustomColumnsTests(TestCase): self.assertEqual(self.a1, Author.objects.get(first_name__exact='John')) def test_filter_on_nonexistent_field(self): - self.assertRaisesMessage( - FieldError, + msg = ( "Cannot resolve keyword 'firstname' into field. Choices are: " - "Author_ID, article, first_name, last_name, primary_set", - Author.objects.filter, - firstname__exact='John' + "Author_ID, article, first_name, last_name, primary_set" ) + with self.assertRaisesMessage(FieldError, msg): + Author.objects.filter(firstname__exact='John') def test_author_get_attributes(self): a = Author.objects.get(last_name__exact='Smith') self.assertEqual('John', a.first_name) self.assertEqual('Smith', a.last_name) - self.assertRaisesMessage( - AttributeError, - "'Author' object has no attribute 'firstname'", - getattr, - a, 'firstname' - ) + with self.assertRaisesMessage(AttributeError, "'Author' object has no attribute 'firstname'"): + getattr(a, 'firstname') - self.assertRaisesMessage( - AttributeError, - "'Author' object has no attribute 'last'", - getattr, - a, 'last' - ) + with self.assertRaisesMessage(AttributeError, "'Author' object has no attribute 'last'"): + getattr(a, 'last') def test_m2m_table(self): self.assertQuerysetEqual( |
