'Test S3Calendar.format_datetime'

def testDateTimeFormatting(self):

    c = S3Calendar()
    render = c.format_datetime
    assertEqual = self.assertEqual
    assertRaises = self.assertRaises
    dt = datetime.datetime(1925, 11, 21, 13, 1, 41)
    dtstr = render(dt)
    assertEqual(dtstr, '1925-11-21T13:01:41')
    settings = current.deployment_settings
    date_format = settings.get_L10n_date_format()
    time_format = settings.get_L10n_time_format()
    try:
        settings.L10n.date_format = '%d/%m/%Y'
        settings.L10n.time_format = '%H.%M'
        dt = datetime.datetime(1964, 8, 24, 13, 21, 0)
        dtstr = render(dt, local=True)
        assertEqual(dtstr, '24/08/1964    13.21')
    finally:
        settings.L10n.date_format = date_format
        settings.L10n.time_format = time_format
    dt = datetime.datetime(2004, 1, 9, 10, 13, 44)
    dtstr = render(dt, dtfmt='%d.%m.%Y    %H:%M:%S')
    assertEqual(dtstr, '09.01.2004    10:13:44')
    try:
        settings.L10n.date_format = '%d/%m/%Y'
        settings.L10n.time_format = '%H.%M'
        dtstr = render(dt, dtfmt='%d.%m.%Y    %H:%M:%S', local=True)
        assertEqual(dtstr, '09.01.2004    10:13:44')
    finally:
        settings.L10n.date_format = date_format
        settings.L10n.time_format = time_format
    dt = None
    dtstr = render(dt)
    assertEqual(dtstr, current.messages.NONE)
    dt = 96
    with assertRaises(TypeError):
        render(dt)
