示例#1
0
文件: helpers.py 项目: Zemanta/sheepy
    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(""), '""')
示例#2
0
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)