Ejemplo n.º 1
0
 def test_unserializable(self):
     """An int can't be serialized."""
     try:
         _json_handler(1)
         success = False
     except TypeError:
         # An int can not be serialized, so, this error is the
         # success.
         success = True
     self.assertTrue(success)
Ejemplo n.º 2
0
 def test_datetime_formatting(self):
     """Test datetime formatting."""
     obj = datetime.datetime(
         year=2012,
         month=9,
         day=11,
         hour=10,
         minute=30,
         second=10,
         microsecond=10
     )
     self.assertEqual(_json_handler(obj), '2012-09-11 10:30:10')