summaryrefslogtreecommitdiff
path: root/tests/forms_tests
diff options
context:
space:
mode:
authorLoic Bistuer <loic.bistuer@gmail.com>2014-10-07 00:09:21 +0700
committerLoic Bistuer <loic.bistuer@gmail.com>2014-10-07 00:14:11 +0700
commit082abce81e48fe9397cce096e13d5199c99adfe9 (patch)
tree5cf6ee0bcc77314035d0663da18a089576b1ff3c /tests/forms_tests
parent2999bf055a121aaa8cc5da7e11fe513107e88f7d (diff)
[1.7.x] Fixed #23594 -- Fixed deepcopy on ErrorList.
Thanks Troy Grosfield for the report and Tim Graham for the tests. Backport of ec2fd02bb3 from master
Diffstat (limited to 'tests/forms_tests')
-rw-r--r--tests/forms_tests/tests/test_util.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/forms_tests/tests/test_util.py b/tests/forms_tests/tests/test_util.py
index 5f0b549bdb..c2dbc5ba8a 100644
--- a/tests/forms_tests/tests/test_util.py
+++ b/tests/forms_tests/tests/test_util.py
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
+import copy
+
from django.core.exceptions import ValidationError
from django.forms.utils import flatatt, ErrorDict, ErrorList
from django.test import TestCase
@@ -66,3 +68,24 @@ class FormsUtilTestCase(TestCase):
'<ul class="errorlist"><li>nameExample of link: &lt;a href=&quot;http://www.example.com/&quot;&gt;example&lt;/a&gt;</li></ul>')
self.assertHTMLEqual(str(ErrorDict({'name': mark_safe(example)})),
'<ul class="errorlist"><li>nameExample of link: <a href="http://www.example.com/">example</a></li></ul>')
+
+ def test_error_dict_copy(self):
+ e = ErrorDict()
+ e['__all__'] = ErrorList([
+ ValidationError(
+ message='message %(i)s',
+ params={'i': 1},
+ ),
+ ValidationError(
+ message='message %(i)s',
+ params={'i': 2},
+ ),
+ ])
+
+ e_copy = copy.copy(e)
+ self.assertEqual(e, e_copy)
+ self.assertEqual(e.as_data(), e_copy.as_data())
+
+ e_deepcopy = copy.deepcopy(e)
+ self.assertEqual(e, e_deepcopy)
+ self.assertEqual(e.as_data(), e_copy.as_data())