def test_datetime_formatters(): dates = [ (datetime(2011, 1, 1), "Sat, 01 Jan 2011 00:00:00 -0000"), (datetime(2011, 1, 1, 23, 59, 59), "Sat, 01 Jan 2011 23:59:59 -0000"), (datetime(2011, 1, 1, 23, 59, 59, tzinfo=UTC()), "Sat, 01 Jan 2011 23:59:59 -0000"), ] for date_obj, expected in dates: yield assert_equal, types.rfc822(date_obj), expected
def test_datetime_formatters(): dates = [ (datetime.datetime(2011, 1, 1), "Sat, 01 Jan 2011 00:00:00 -0000"), (datetime.datetime(2011, 1, 1, 23, 59, 59), "Sat, 01 Jan 2011 23:59:59 -0000"), (datetime.datetime(2011, 1, 1, 23, 59, 59, tzinfo=UTC()), "Sat, 01 Jan 2011 23:59:59 -0000"), ] for date_obj, expected in dates: yield assert_equals, types.rfc822(date_obj), expected
def format(self, value): try: return types.rfc822(value) except AttributeError as ae: raise MarshallingException(ae)