summaryrefslogtreecommitdiff
path: root/tests/forms_tests
diff options
context:
space:
mode:
authorAndrey Maslov <greyzmeem@gmail.com>2014-12-23 17:51:36 +0200
committerTim Graham <timograham@gmail.com>2014-12-31 14:43:13 -0500
commit7a878ca5cb50ad65fc465cb263a44cc93629f75c (patch)
tree98954da265940ab1010e46dee2179f813dacb027 /tests/forms_tests
parenta1487deebff7bf27a4946a9f5ddd68154fa4834d (diff)
Fixed #24008 -- Fixed ValidationError crash with list of dicts.
Diffstat (limited to 'tests/forms_tests')
-rw-r--r--tests/forms_tests/tests/test_utils.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/tests/forms_tests/tests/test_utils.py b/tests/forms_tests/tests/test_utils.py
index 6e40e7565c..9f412b7a27 100644
--- a/tests/forms_tests/tests/test_utils.py
+++ b/tests/forms_tests/tests/test_utils.py
@@ -65,9 +65,31 @@ class FormsUtilsTestCase(TestCase):
self.assertHTMLEqual(str(ErrorList(ValidationError(["Error one.", "Error two."]).messages)),
'<ul class="errorlist"><li>Error one.</li><li>Error two.</li></ul>')
+ # Can take a dict.
+ self.assertHTMLEqual(
+ str(ErrorList(sorted(ValidationError({'error_1': "1. Error one.", 'error_2': "2. Error two."}).messages))),
+ '<ul class="errorlist"><li>1. Error one.</li><li>2. Error two.</li></ul>'
+ )
+
# Can take a mixture in a list.
- self.assertHTMLEqual(str(ErrorList(ValidationError(["First error.", "Not \u03C0.", ugettext_lazy("Error.")]).messages)),
- '<ul class="errorlist"><li>First error.</li><li>Not π.</li><li>Error.</li></ul>')
+ self.assertHTMLEqual(
+ str(ErrorList(sorted(ValidationError([
+ "1. First error.",
+ "2. Not \u03C0.",
+ ugettext_lazy("3. Error."),
+ {
+ 'error_1': "4. First dict error.",
+ 'error_2': "5. Second dict error.",
+ },
+ ]).messages))),
+ '<ul class="errorlist">'
+ '<li>1. First error.</li>'
+ '<li>2. Not π.</li>'
+ '<li>3. Error.</li>'
+ '<li>4. First dict error.</li>'
+ '<li>5. Second dict error.</li>'
+ '</ul>'
+ )
@python_2_unicode_compatible
class VeryBadError: