Author: gwilson
Date: 2007-09-13 21:01:11 -0500 (Thu, 13 Sep 2007)
New Revision: 6150
Added:
django/trunk/tests/regressiontests/forms/util.py
Modified:
django/trunk/tests/regressiontests/forms/tests.py
Log:
Refs #5370 -- Added tests for ValidationError messages.
Modified: django/trunk/tests/regressiontests/forms/tests.py
===================================================================
--- django/trunk/tests/regressiontests/forms/tests.py 2007-09-14 01:52:10 UTC
(rev 6149)
+++ django/trunk/tests/regressiontests/forms/tests.py 2007-09-14 02:01:11 UTC
(rev 6150)
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from localflavor import localflavor_tests
from regressions import regression_tests
+from util import util_tests
form_tests = r"""
>>> from django.newforms import *
@@ -3852,6 +3853,7 @@
'form_tests': form_tests,
'localflavor': localflavor_tests,
'regressions': regression_tests,
+ 'util_tests': util_tests,
}
if __name__ == "__main__":
Added: django/trunk/tests/regressiontests/forms/util.py
===================================================================
--- django/trunk/tests/regressiontests/forms/util.py
(rev 0)
+++ django/trunk/tests/regressiontests/forms/util.py 2007-09-14 02:01:11 UTC
(rev 6150)
@@ -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>
+"""
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---