예제 #1
0
 def test_creates_error_dict_from_error_list_if_validation_error_only_has_error_list(
         self):
     obj = InvalidRow(number=1,
                      validation_error=self.non_field_errors,
                      values=[])
     self.assertIsInstance(obj.error_dict, dict)
     self.assertIn(NON_FIELD_ERRORS, obj.error_dict)
     self.assertEqual(obj.error_dict[NON_FIELD_ERRORS],
                      ['Error 1', 'Error 2', 'Error 3'])
예제 #2
0
 def setUp(self):
     # Create a ValidationError with a mix of field-specific and non-field-specific errors
     self.non_field_errors = ValidationError(
         ['Error 1', 'Error 2', 'Error 3'])
     self.field_errors = ValidationError({
         'name': ['Error 4', 'Error 5'],
         'birthday': ['Error 6', 'Error 7'],
     })
     combined_error_dict = self.non_field_errors.update_error_dict(
         self.field_errors.error_dict.copy())
     e = ValidationError(combined_error_dict)
     # Create an InvalidRow instance to use in tests
     self.obj = InvalidRow(number=1,
                           validation_error=e,
                           values=['ABC', '123'])