2013-08-08 20:03:45 +08:00
|
|
|
from test.test_json import CTest
|
2008-05-08 22:29:10 +08:00
|
|
|
|
|
|
|
|
2011-05-14 11:47:51 +08:00
|
|
|
class TestSpeedups(CTest):
|
2008-05-08 22:29:10 +08:00
|
|
|
def test_scanstring(self):
|
2011-05-14 11:47:51 +08:00
|
|
|
self.assertEqual(self.json.decoder.scanstring.__module__, "_json")
|
|
|
|
self.assertIs(self.json.decoder.scanstring, self.json.decoder.c_scanstring)
|
2008-05-08 22:29:10 +08:00
|
|
|
|
|
|
|
def test_encode_basestring_ascii(self):
|
2011-05-14 11:47:51 +08:00
|
|
|
self.assertEqual(self.json.encoder.encode_basestring_ascii.__module__,
|
|
|
|
"_json")
|
|
|
|
self.assertIs(self.json.encoder.encode_basestring_ascii,
|
|
|
|
self.json.encoder.c_encode_basestring_ascii)
|
|
|
|
|
2009-12-09 00:00:03 +08:00
|
|
|
|
2011-05-14 11:47:51 +08:00
|
|
|
class TestDecode(CTest):
|
2009-12-09 00:00:03 +08:00
|
|
|
def test_make_scanner(self):
|
2011-05-14 11:47:51 +08:00
|
|
|
self.assertRaises(AttributeError, self.json.scanner.c_make_scanner, 1)
|
2009-12-09 00:00:03 +08:00
|
|
|
|
|
|
|
def test_make_encoder(self):
|
2011-05-14 11:47:51 +08:00
|
|
|
self.assertRaises(TypeError, self.json.encoder.c_make_encoder,
|
2009-12-09 00:00:03 +08:00
|
|
|
(True, False),
|
|
|
|
b"\xCD\x7D\x3D\x4E\x12\x4C\xF9\x79\xD7\x52\xBA\x82\xF2\x27\x4A\x7D\xA0\xCA\x75",
|
|
|
|
None)
|