Ticket #22290: 22290-test.diff

File 22290-test.diff, 1.7 KB (added by Claude Paroz, 11 years ago)
  • tests/forms_tests/tests/test_forms.py

    diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py
    index c05c79a..b1841e0 100644
    a b from django.forms.utils import ErrorList  
    1919from django.http import QueryDict
    2020from django.template import Template, Context
    2121from django.test import TestCase
    22 from django.test.utils import str_prefix
     22from django.test.utils import override_settings, str_prefix
    2323from django.utils.datastructures import MultiValueDict, MergeDict
    2424from django.utils.safestring import mark_safe
    2525from django.utils import six
    class FormsTestCase(TestCase):  
    12721272        self.assertFalse(p.is_valid())
    12731273        self.assertIn('pedantic', p.changed_data)
    12741274
     1275    @override_settings(USE_L10N=False, DATE_INPUT_FORMATS=('%d.%m.%Y', '%Y-%m-%d'))
     1276    def test_changed_data_date_hidden(self):
     1277        class PersonForm(Form):
     1278            name = CharField()
     1279            birthday = DateField(show_hidden_initial=True)
     1280
     1281        form = PersonForm(initial={'birthday': datetime.date(1974, 8, 16)})
     1282        self.assertInHTML(
     1283            '<input id="initial-id_birthday" name="initial-birthday" type="hidden" value="1974-08-16" />',
     1284            form.as_ul())
     1285        form = PersonForm(
     1286            data={'name': 'John', 'birthday': '16.8.1974', 'initial-birthday': '1974-08-16'},
     1287            initial={'name': 'John', 'birthday': datetime.date(1974, 8, 16)}
     1288        )
     1289        self.assertFalse(form.has_changed())
     1290
    12751291    def test_boundfield_values(self):
    12761292        # It's possible to get to the value which would be used for rendering
    12771293        # the widget for a field by using the BoundField's value method.
Back to Top