# coding: utf-8
"""
Tests for forms/util.py module.
"""
tests = r"""
>>> from django.forms.util import *
>>> from django.utils.translation import ugettext_lazy
###########
# flatatt #
###########
>>> from django.forms.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
>>> class VeryBadError:
... def __unicode__(self): return u"A very bad error."
# Can take a non-string.
>>> print ValidationError(VeryBadError()).messages
# Escapes non-safe input but not input marked safe.
>>> example = 'Example of link: example'
>>> print ValidationError(example).messages
- Example of link: <a href="http://www.example.com/">example</a>
>>> print ValidationError(mark_safe(example)).messages
"""