Ticket #17134: 17134_datetime_bug_tests.diff

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

Tests that show the bug on python < 2.6

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

    diff -r 6fbe58966536 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_4(self):
     457        f = DateTimeField(input_formats=[u'%Y.%m.%s %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