Ticket #13339: ticket_13339_l10n_month_tests.diff

File ticket_13339_l10n_month_tests.diff, 2.1 KB (added by Ulrich Petri, 15 years ago)
  • regressiontests/i18n/tests.py

     
    1111from django.test import TestCase
    1212from django.utils.translation import ugettext, ugettext_lazy, activate, deactivate, gettext_lazy, to_locale
    1313
    14 from forms import I18nForm, SelectDateForm, SelectDateWidget, CompanyForm
     14from forms import I18nForm, SelectDateForm, SelectDateWidget, CompanyForm, SimpleDateForm
    1515
    1616
    1717class TranslationTests(TestCase):
     
    411411            settings.USE_THOUSAND_SEPARATOR = True
    412412            # Checking for the localized "products_delivered" field
    413413            self.assert_(u'<input type="text" name="products_delivered" value="12.000" id="id_products_delivered" />' in form6.as_ul())
     414           
     415            form7 = CompanyForm({
     416                'name': u'acme',
     417                'date_added': "31.12.2009 12:31",
     418                'cents_payed': "59,47",
     419                'products_delivered': "12.000",
     420            })
     421            self.assertEqual(True, form7.is_valid())
     422
     423            form8 = SimpleDateForm({
     424                'date_field': "31. Dezember 2009",
     425            })
     426            self.assertEqual(True, form8.is_valid())
     427            self.assertEqual(
     428                form8.as_ul(),
     429                u'<li><label for="id_date_field">Date field:</label> <input type="text" name="date_field" value="31. Dezember 2009" id="id_date_field" /></li>'
     430            )
     431
     432
    414433        finally:
    415434            deactivate()
    416435
  • regressiontests/i18n/forms.py

     
    1515
    1616class CompanyForm(forms.ModelForm):
    1717    cents_payed = forms.DecimalField(max_digits=4, decimal_places=2, localize=True)
     18    date_added = forms.DateTimeField(localize=True)
    1819    products_delivered = forms.IntegerField(localize=True)
    1920
    2021    class Meta:
    2122        model = Company
     23
     24class SimpleDateForm(forms.Form):
     25    date_field = forms.DateField()
Back to Top