2014-11-20 19:26:48 +00:00
|
|
|
import unittest
|
|
|
|
|
|
|
|
from django.core.exceptions import ValidationError
|
|
|
|
|
|
|
|
|
|
|
|
class TestValidationError(unittest.TestCase):
|
|
|
|
def test_messages_concatenates_error_dict_values(self):
|
|
|
|
message_dict = {}
|
2014-11-12 23:06:12 +00:00
|
|
|
exception = ValidationError(message_dict)
|
|
|
|
self.assertEqual(sorted(exception.messages), [])
|
2014-11-20 19:26:48 +00:00
|
|
|
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'])
|