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

@ -60,7 +60,11 @@ class OnDeleteTests(TestCase):
def test_protect(self):
a = create_a('protect')
with self.assertRaises(IntegrityError):
msg = (
"Cannot delete some instances of model 'R' because they are "
"referenced through a protected foreign key: 'A.protect'"
)
with self.assertRaisesMessage(IntegrityError, msg):
a.protect.delete()
def test_do_nothing(self):