mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Refs #5370 -- Added tests for ValidationError messages.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6150 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
33
tests/regressiontests/forms/util.py
Normal file
33
tests/regressiontests/forms/util.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# coding: utf-8
|
||||
"""
|
||||
Tests for newforms/util.py module.
|
||||
"""
|
||||
|
||||
util_tests = r"""
|
||||
>>> from django.newforms.util import *
|
||||
>>> from django.utils.translation import ugettext_lazy
|
||||
|
||||
###################
|
||||
# ValidationError #
|
||||
###################
|
||||
|
||||
# Can take a string.
|
||||
>>> print ValidationError("There was an error.").messages
|
||||
<ul class="errorlist"><li>There was an error.</li></ul>
|
||||
|
||||
# Can take a unicode string.
|
||||
>>> print ValidationError(u"Not \u03C0.").messages
|
||||
<ul class="errorlist"><li>Not π.</li></ul>
|
||||
|
||||
# Can take a lazy string.
|
||||
>>> print ValidationError(ugettext_lazy("Error.")).messages
|
||||
<ul class="errorlist"><li>Error.</li></ul>
|
||||
|
||||
# Can take a list.
|
||||
>>> print ValidationError(["Error one.", "Error two."]).messages
|
||||
<ul class="errorlist"><li>Error one.</li><li>Error two.</li></ul>
|
||||
|
||||
# Can take a mixture in a list.
|
||||
>>> print ValidationError(["First error.", u"Not \u03C0.", ugettext_lazy("Error.")]).messages
|
||||
<ul class="errorlist"><li>First error.</li><li>Not π.</li><li>Error.</li></ul>
|
||||
"""
|
||||
Reference in New Issue
Block a user