# -*- coding: utf-8 -*- # Tests to prevent against recurrences of earlier bugs. tests = r""" It should be possible to re-use attribute dictionaries (#3810) >>> from django.newforms import * >>> extra_attrs = {'class': 'special'} >>> class TestForm(Form): ... f1 = CharField(max_length=10, widget=TextInput(attrs=extra_attrs)) ... f2 = CharField(widget=TextInput(attrs=extra_attrs)) >>> TestForm(auto_id=False).as_p() u'
F1:
\nF2:
' ####################### # Tests for form i18n # ####################### There were some problems with form translations in #3600 >>> from django.utils.translation import ugettext_lazy, activate, deactivate >>> class SomeForm(Form): ... username = CharField(max_length=10, label=ugettext_lazy('Username')) >>> f = SomeForm() >>> print f.as_p()Translations are done at rendering time, so multi-lingual apps can define forms early and still send back the right translation. # XFAIL >>> activate('de') >>> print f.as_p()
>>> activate('pl') >>> f.as_p() u'
' >>> deactivate() Unicode decoding problems... >>> GENDERS = ((u'\xc5', u'En tied\xe4'), (u'\xf8', u'Mies'), (u'\xdf', u'Nainen')) >>> class SomeForm(Form): ... somechoice = ChoiceField(choices=GENDERS, widget=RadioSelect(), label=u'\xc5\xf8\xdf') >>> f = SomeForm() >>> f.as_p() u'