Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #5370 -- Added tests for ValidationError messages.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6150 bcc190cf-cafb-0310-a4f2-bffc1f526a37
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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> | |||
""" |