Ticket #21555: ticket-21555-rev1.patch

File ticket-21555-rev1.patch, 1.1 KB (added by Alex Hayes, 11 years ago)
  • django/core/exceptions.py

    diff --git a/django/core/exceptions.py b/django/core/exceptions.py
    index 87b173b..bbb79cb 100644
    a b class ValidationError(Exception):  
    112112            self.code = code
    113113            self.params = params
    114114            self.error_list = [self]
     115       
     116        super(ValidationError, self).__init__(None)
    115117
    116118    @property
    117119    def message_dict(self):
  • new file tests/validation/test_picklable.py

    diff --git a/tests/validation/test_picklable.py b/tests/validation/test_picklable.py
    new file mode 100644
    index 0000000..b494bf9
    - +  
     1from django.core.exceptions import ValidationError
     2from django.test import TestCase
     3import pickle
     4
     5class PickableValidationErrorTestCase(TestCase):
     6
     7    def test_validationerror_is_picklable(self):
     8        expected = ValidationError(['a', 'b'])
     9        actual = pickle.loads(pickle.dumps(expected))
     10       
     11        self.assertEqual(actual.error_list[0].message, expected.error_list[0].message)
     12        self.assertEqual(actual.error_list[1].message, expected.error_list[1].message)
Back to Top