1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00
django/tests/test_exceptions/test_validation_error.py
Brad Walker cfa26f29bd Reduced reduce() usage; refs #23796.
django.core.exceptions.ValidationError.messages() and
django.db.backends.schema.BaseDatabaseSchemaEditor._alter_field():
Replaced reduce(operator.add, ...) w/uncoupled, explicit sum()
2014-11-20 14:31:14 -05:00

17 lines
647 B
Python

import unittest
from django.core.exceptions import ValidationError
class TestValidationError(unittest.TestCase):
def test_messages_concatenates_error_dict_values(self):
message_dict = {}
exception = ValidationError(message_dict)
self.assertEqual(sorted(exception.messages), [])
message_dict['field1'] = ['E1', 'E2']
exception = ValidationError(message_dict)
self.assertEqual(sorted(exception.messages), ['E1', 'E2'])
message_dict['field2'] = ['E3', 'E4']
exception = ValidationError(message_dict)
self.assertEqual(sorted(exception.messages), ['E1', 'E2', 'E3', 'E4'])