1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Used assertRaisesMessage() to test Django's error messages.

This commit is contained in:
Mads Jensen
2017-05-28 21:37:21 +02:00
committed by Tim Graham
parent 38988f289f
commit a51c4de194
69 changed files with 448 additions and 173 deletions

View File

@@ -118,7 +118,11 @@ class EarliestOrLatestTests(TestCase):
# "get_latest_by" set -- just pass in the field name manually.
Person.objects.create(name="Ralph", birthday=datetime(1950, 1, 1))
p2 = Person.objects.create(name="Stephanie", birthday=datetime(1960, 2, 3))
with self.assertRaises(AssertionError):
msg = (
"earliest() and latest() require either a field_name parameter or "
"'get_latest_by' in the model"
)
with self.assertRaisesMessage(AssertionError, msg):
Person.objects.latest()
self.assertEqual(Person.objects.latest("birthday"), p2)