summaryrefslogtreecommitdiff
path: root/tests/regressiontests/forms/util.py
diff options
context:
space:
mode:
authorJustin Bronn <jbronn@gmail.com>2007-09-20 13:02:11 +0000
committerJustin Bronn <jbronn@gmail.com>2007-09-20 13:02:11 +0000
commit7376474260a967e7ad88ee5bf554b4a28e3e7feb (patch)
tree735479f07bbe7cde8385b44ff76552afc9c2bffc /tests/regressiontests/forms/util.py
parent69452d623794bc9ef160c33c5e9b02180ca4848d (diff)
gis: Merged revisions 6021-6393 via svnmerge from [repos:django/trunk trunk].
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@6394 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/forms/util.py')
-rw-r--r--tests/regressiontests/forms/util.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/regressiontests/forms/util.py b/tests/regressiontests/forms/util.py
new file mode 100644
index 0000000000..4f81709082
--- /dev/null
+++ b/tests/regressiontests/forms/util.py
@@ -0,0 +1,45 @@
+# coding: utf-8
+"""
+Tests for newforms/util.py module.
+"""
+
+tests = r"""
+>>> from django.newforms.util import *
+>>> from django.utils.translation import ugettext_lazy
+
+###########
+# flatatt #
+###########
+
+>>> from django.newforms.util import flatatt
+>>> flatatt({'id': "header"})
+u' id="header"'
+>>> flatatt({'class': "news", 'title': "Read this"})
+u' class="news" title="Read this"'
+>>> flatatt({})
+u''
+
+###################
+# 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>
+"""