def test_can_encode_objects_with_str_method(self): class CustomObject(object): def __str__(self): return "Wahoo" obj = CustomObject() self.assertEqual(util.json_encoder(obj), "Wahoo")
def test_can_encode_date(self): date = datetime.date(year=2012, month=1, day=1) encoded = util.json_encoder(date) self.assertEqual(encoded, "2012-01-01")
def test_can_encode_datetime(self): date_time = datetime.datetime( year=2012, month=1, day=1, hour=1, minute=1, second=1) encoded = util.json_encoder(date_time) self.assertEqual(encoded, "2012-01-01T01:01:01")