Refs #26022 -- Used context manager version of assertRaisesMessage in tests.

This commit is contained in:
Hasan 2016-01-04 12:20:08 +03:30 committed by Tim Graham
parent 3d0dcd7f5a
commit 253adc2b8a
21 changed files with 584 additions and 566 deletions

View file

@ -318,7 +318,8 @@ class BasicExpressionsTests(TestCase):
'expressions.Company.num_employees. F() expressions can only be '
'used to update, not to insert.'
)
self.assertRaisesMessage(ValueError, msg, acme.save)
with self.assertRaisesMessage(ValueError, msg):
acme.save()
acme.num_employees = 12
acme.name = Lower(F('name'))
@ -327,7 +328,8 @@ class BasicExpressionsTests(TestCase):
'expressions.Company.name))" on expressions.Company.name. F() '
'expressions can only be used to update, not to insert.'
)
self.assertRaisesMessage(ValueError, msg, acme.save)
with self.assertRaisesMessage(ValueError, msg):
acme.save()
def test_ticket_11722_iexact_lookup(self):
Employee.objects.create(firstname="John", lastname="Doe")