diff --git a/tests/regressiontests/forms/tests.py b/tests/regressiontests/forms/tests.py index 2477eb1cef..1f865513c8 100644 --- a/tests/regressiontests/forms/tests.py +++ b/tests/regressiontests/forms/tests.py @@ -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 @@ __test__ = { 'form_tests': form_tests, 'localflavor': localflavor_tests, 'regressions': regression_tests, + 'util_tests': util_tests, } if __name__ == "__main__": diff --git a/tests/regressiontests/forms/util.py b/tests/regressiontests/forms/util.py new file mode 100644 index 0000000000..b0b50e3be9 --- /dev/null +++ b/tests/regressiontests/forms/util.py @@ -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 + + +# 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 + +"""