diff options
author | Brad Walker <brad@bradmwalker.com> | 2014-11-20 14:26:48 -0500 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2014-11-20 14:31:14 -0500 |
commit | f273cedc76eded138e0418c9db0b425e40797633 (patch) | |
tree | da7d10c8fccd18d7d075dc0488a4087994be4e82 /tests/test_exceptions | |
parent | 5c481db29572a387651681b43d5d4523f96b3793 (diff) | |
download | django-f273cedc76eded138e0418c9db0b425e40797633.tar.gz |
Added test for ValidationError.messages
Diffstat (limited to 'tests/test_exceptions')
-rw-r--r-- | tests/test_exceptions/__init__.py | 0 | ||||
-rw-r--r-- | tests/test_exceptions/test_validation_error.py | 16 |
2 files changed, 16 insertions, 0 deletions
diff --git a/tests/test_exceptions/__init__.py b/tests/test_exceptions/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/test_exceptions/__init__.py diff --git a/tests/test_exceptions/test_validation_error.py b/tests/test_exceptions/test_validation_error.py new file mode 100644 index 0000000000..ee91fc75b4 --- /dev/null +++ b/tests/test_exceptions/test_validation_error.py @@ -0,0 +1,16 @@ +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']) |