mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
[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
This commit is contained in:
@@ -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: <a href="http://www.example.com/">example</a></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())
|
||||
|
||||
Reference in New Issue
Block a user