Skip to content

Commit 5e998d7

Browse files
adamchainzsarahboyce
authored andcommitted
Refs #35987 -- Added extra tests for ErrorList and ErrorDict copy methods.
1 parent 4806c42 commit 5e998d7

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/forms_tests/tests/test_utils.py

+28
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,24 @@ def __str__(self):
162162
'<a href="http://www.example.com/">example</a></li></ul>',
163163
)
164164

165+
def test_error_list_copy(self):
166+
e = ErrorList(
167+
[
168+
ValidationError(
169+
message="message %(i)s",
170+
params={"i": 1},
171+
),
172+
ValidationError(
173+
message="message %(i)s",
174+
params={"i": 2},
175+
),
176+
]
177+
)
178+
179+
e_copy = copy.copy(e)
180+
self.assertEqual(e, e_copy)
181+
self.assertEqual(e.as_data(), e_copy.as_data())
182+
165183
def test_error_list_copy_attributes(self):
166184
class CustomRenderer(DjangoTemplates):
167185
pass
@@ -195,6 +213,16 @@ def test_error_dict_copy(self):
195213
e_deepcopy = copy.deepcopy(e)
196214
self.assertEqual(e, e_deepcopy)
197215

216+
def test_error_dict_copy_attributes(self):
217+
class CustomRenderer(DjangoTemplates):
218+
pass
219+
220+
renderer = CustomRenderer()
221+
e = ErrorDict(renderer=renderer)
222+
223+
e_copy = copy.copy(e)
224+
self.assertEqual(e.renderer, e_copy.renderer)
225+
198226
def test_error_dict_html_safe(self):
199227
e = ErrorDict()
200228
e["username"] = "Invalid username."

0 commit comments

Comments
 (0)