Fix tests.

This commit is contained in:
Waldecir Santos 2018-07-22 23:53:58 +01:00
parent c1bd3c4c15
commit d4a9c2bb89

View File

@ -132,8 +132,10 @@ class ModelFormMutationTests(TestCase):
# A pet was not created # A pet was not created
self.assertEqual(Pet.objects.count(), 0) self.assertEqual(Pet.objects.count(), 0)
fields_w_error = [e.field for e in result.errors]
self.assertEqual(len(result.errors), 2) self.assertEqual(len(result.errors), 2)
self.assertEqual(result.errors[0].field, "name") self.assertIn("name", fields_w_error)
self.assertEqual(result.errors[0].messages, ["This field is required."]) self.assertEqual(result.errors[0].messages, ["This field is required."])
self.assertEqual(result.errors[1].field, "age") self.assertIn("age", fields_w_error)
self.assertEqual(result.errors[1].messages, ["This field is required."]) self.assertEqual(result.errors[1].messages, ["This field is required."])