def test_valid(self): enc = SheepyEncoder() self.assertEqual(enc.encode((1, 2.0, "3")), '[1,2.0,"3"]') self.assertEqual(enc.encode([1, 2.0, "3"]), '[1,2.0,"3"]') self.assertEqual(enc.encode(('"',)), '["\\""]') self.assertEqual(enc.encode(1), "1") self.assertEqual(enc.encode(1.0), "1.0") self.assertEqual(enc.encode(""), '""')
class _BaseProtocol(object): def __init__(self): self._encoder = SheepyEncoder() def _json_encode(self, tpl): return self._encoder.encode(tpl) def _json_decode(self, string): return json.loads(string)