From fb6a0c8ffa1cd74c63aaf4b011665e5952d449e7 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Sat, 15 Sep 2007 21:21:37 +0000 Subject: queryset-refactor: Merged to [6155] git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6332 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/forms/util.py | 45 +++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/regressiontests/forms/util.py (limited to 'tests/regressiontests/forms/util.py') diff --git a/tests/regressiontests/forms/util.py b/tests/regressiontests/forms/util.py new file mode 100644 index 0000000000..1a02b7e55b --- /dev/null +++ b/tests/regressiontests/forms/util.py @@ -0,0 +1,45 @@ +# coding: utf-8 +""" +Tests for newforms/util.py module. +""" + +util_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 + + +# Can take a unicode string. +>>> print ValidationError(u"Not \u03C0.").messages + + +# Can take a lazy string. +>>> print ValidationError(ugettext_lazy("Error.")).messages + + +# Can take a list. +>>> print ValidationError(["Error one.", "Error two."]).messages + + +# Can take a mixture in a list. +>>> print ValidationError(["First error.", u"Not \u03C0.", ugettext_lazy("Error.")]).messages + +""" -- cgit v1.3