Ticket #17134: 17134_datetime_bug_tests.2.diff

File 17134_datetime_bug_tests.2.diff, 1.5 KB (added by Cliff Dyer, 7 years ago)

Test to exercise the bug in python < 2.6

  • tests/regressiontests/forms/tests/fields.py

    diff -r 0323b4125cec tests/regressiontests/forms/tests/fields.py
    a b  
    407407        self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30, 59), f.clean(datetime.datetime(2006, 10, 25, 14, 30, 59)))
    408408        self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30, 59, 200), f.clean(datetime.datetime(2006, 10, 25, 14, 30, 59, 200)))
    409409        self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30, 45, 200), f.clean('2006-10-25 14:30:45.000200'))
     410        self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30, 45, 200), f.clean('2006-10-25 14:30:45.0002'))
    410411        self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30, 45), f.clean('2006-10-25 14:30:45'))
    411412        self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30), f.clean('2006-10-25 14:30:00'))
    412413        self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30), f.clean('2006-10-25 14:30'))
     
    452453        self.assertEqual(datetime.datetime(2006, 10, 25, 0, 0), f.clean(' 10/25/06 '))
    453454        self.assertRaisesMessage(ValidationError, "[u'Enter a valid date/time.']", f.clean, '   ')
    454455
     456    def test_datetimefield_5(self):
     457        f = DateTimeField(input_formats=[u'%Y.%m.%d %H:%M:%S.%f'])
     458        self.assertEqual(datetime.datetime(2006, 10, 25, 14, 30, 45, 200), f.clean('2006.10.25 14:30:45.0002'))
    455459    # RegexField ##################################################################
    456460
    457461    def test_regexfield_1(self):
Back to Top