'Test S3Calendar.format_date'

def testDateFormatting(self):

    c = S3Calendar()
    render = c.format_date
    assertEqual = self.assertEqual
    assertRaises = self.assertRaises
    dt = datetime.date(1925, 11, 21)
    dtstr = render(dt)
    assertEqual(dtstr, '1925-11-21')
    settings = current.deployment_settings
    date_format = settings.get_L10n_date_format()
    try:
        settings.L10n.date_format = '%d/%m/%Y'
        dt = datetime.date(1983, 5, 8)
        dtstr = render(dt, local=True)
        assertEqual(dtstr, '08/05/1983')
    finally:
        settings.L10n.date_format = date_format
    dt = datetime.date(2004, 1, 9)
    dtstr = render(dt, dtfmt='%d.%m.%Y')
    assertEqual(dtstr, '09.01.2004')
    try:
        settings.L10n.date_format = '%d/%m/%Y'
        dtstr = render(dt, dtfmt='%d.%m.%Y', local=True)
        assertEqual(dtstr, '09.01.2004')
    finally:
        settings.L10n.date_format = date_format
    dt = None
    dtstr = render(dt)
    assertEqual(dtstr, current.messages.NONE)
    dt = 96
    with assertRaises(TypeError):
        render(dt)
