def serialize(obj): doc = {} for k, v in six.iteritems(obj.__dict__): if isinstance(v, SERIALIZABLE_TYPES): doc[k] = date.format(v) if date.valid(v) else v return doc
def test_date_format(self): offset = dateutil.tz.tzoffset(None, 3600) dt = datetime.datetime(2015, 1, 1, 12, 0, 1, tzinfo=offset) expected = "2015-01-01T12:00:01.000000+01:00" self.assertEqual(expected, date.format(dt))