Kaydet (Commit) f273cedc authored tarafından Brad Walker's avatar Brad Walker Kaydeden (comit) Tim Graham

Added test for ValidationError.messages

üst 5c481db2
import unittest
from django.core.exceptions import ValidationError
class TestValidationError(unittest.TestCase):
def test_messages_concatenates_error_dict_values(self):
message_dict = {}
with self.assertRaises(TypeError):
ValidationError(message_dict).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'])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment