mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Used assertRaisesMessage() to test Django's error messages.
This commit is contained in:
parent
38988f289f
commit
a51c4de194
69 changed files with 448 additions and 173 deletions
|
@ -246,7 +246,8 @@ class BasicExpressionsTests(TestCase):
|
|||
)
|
||||
|
||||
with transaction.atomic():
|
||||
with self.assertRaises(FieldError):
|
||||
msg = "Joined field references are not permitted in this query"
|
||||
with self.assertRaisesMessage(FieldError, msg):
|
||||
Company.objects.exclude(
|
||||
ceo__firstname=F('point_of_contact__firstname')
|
||||
).update(name=F('point_of_contact__lastname'))
|
||||
|
@ -293,13 +294,15 @@ class BasicExpressionsTests(TestCase):
|
|||
|
||||
def test():
|
||||
test_gmbh.point_of_contact = F("ceo")
|
||||
with self.assertRaises(ValueError):
|
||||
msg = 'F(ceo)": "Company.point_of_contact" must be a "Employee" instance.'
|
||||
with self.assertRaisesMessage(ValueError, msg):
|
||||
test()
|
||||
|
||||
test_gmbh.point_of_contact = test_gmbh.ceo
|
||||
test_gmbh.save()
|
||||
test_gmbh.name = F("ceo__last_name")
|
||||
with self.assertRaises(FieldError):
|
||||
msg = 'Joined field references are not permitted in this query'
|
||||
with self.assertRaisesMessage(FieldError, msg):
|
||||
test_gmbh.save()
|
||||
|
||||
def test_object_update_unsaved_objects(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue