コード例 #1
0
 def test_dump_json_should_allow_datetime_date(self):
     self.assertEqual(dump_json(
         datetime.date(2018, 10, 20)),
         '"2018-10-20"'
     )
     self.assertEqual(dump_json(
         {'date': datetime.date(2018, 10, 20)}),
         '{"date":"2018-10-20"}'
     )
コード例 #2
0
 def test_dump_json_should_allow_numpy_int64(self):
     self.assertEqual(dump_json(numpy.int64(1)), '1')
     self.assertEqual(dump_json({'num': numpy.int64(1)}), '{"num":1}')
コード例 #3
0
 def test_dump_json(self):
     data = {'a': numpy.int64(3), 'b': numpy.float64(3)}
     roundtrip = json.loads(dump_json(data))
     for key, value in iteritems(data):
         self.assertEqual(data[key], roundtrip[key])