Hackfut Security File Manager
Current Path:
/opt/alt/python27/lib64/python2.7/site-packages/simplejson/tests
opt
/
alt
/
python27
/
lib64
/
python2.7
/
site-packages
/
simplejson
/
tests
/
📁
..
📄
__init__.py
(2.03 KB)
📄
__init__.pyc
(2.96 KB)
📄
__init__.pyo
(2.96 KB)
📄
test_check_circular.py
(917 B)
📄
test_check_circular.pyc
(2.21 KB)
📄
test_check_circular.pyo
(2.21 KB)
📄
test_decimal.py
(1.91 KB)
📄
test_decimal.pyc
(2.87 KB)
📄
test_decimal.pyo
(2.87 KB)
📄
test_decode.py
(3.21 KB)
📄
test_decode.pyc
(5.22 KB)
📄
test_decode.pyo
(5.22 KB)
📄
test_default.py
(222 B)
📄
test_default.pyc
(791 B)
📄
test_default.pyo
(791 B)
📄
test_dump.py
(984 B)
📄
test_dump.pyc
(2.04 KB)
📄
test_dump.pyo
(2.04 KB)
📄
test_encode_basestring_ascii.py
(2.25 KB)
📄
test_encode_basestring_ascii.pyc
(3.58 KB)
📄
test_encode_basestring_ascii.pyo
(3.58 KB)
📄
test_encode_for_html.py
(1.05 KB)
📄
test_encode_for_html.pyc
(1.95 KB)
📄
test_encode_for_html.pyo
(1.95 KB)
📄
test_errors.py
(1 KB)
📄
test_errors.pyc
(1.85 KB)
📄
test_errors.pyo
(1.85 KB)
📄
test_fail.py
(3.47 KB)
📄
test_fail.pyc
(2.64 KB)
📄
test_fail.pyo
(2.64 KB)
📄
test_float.py
(743 B)
📄
test_float.pyc
(1.38 KB)
📄
test_float.pyo
(1.38 KB)
📄
test_indent.py
(2.51 KB)
📄
test_indent.pyc
(2.98 KB)
📄
test_indent.pyo
(2.98 KB)
📄
test_namedtuple.py
(2.47 KB)
📄
test_namedtuple.pyc
(3.39 KB)
📄
test_namedtuple.pyo
(3.39 KB)
📄
test_pass1.py
(1.86 KB)
📄
test_pass1.pyc
(2.31 KB)
📄
test_pass1.pyo
(2.31 KB)
📄
test_pass2.py
(387 B)
📄
test_pass2.pyc
(867 B)
📄
test_pass2.pyo
(867 B)
📄
test_pass3.py
(483 B)
📄
test_pass3.pyc
(962 B)
📄
test_pass3.pyo
(962 B)
📄
test_recursion.py
(1.64 KB)
📄
test_recursion.pyc
(2.64 KB)
📄
test_recursion.pyo
(2.64 KB)
📄
test_scanstring.py
(3.96 KB)
📄
test_scanstring.pyc
(4.71 KB)
📄
test_scanstring.pyo
(4.71 KB)
📄
test_separators.py
(945 B)
📄
test_separators.pyc
(1.56 KB)
📄
test_separators.pyo
(1.56 KB)
📄
test_speedups.py
(592 B)
📄
test_speedups.pyc
(1.34 KB)
📄
test_speedups.pyo
(1.34 KB)
📄
test_tuple.py
(1.8 KB)
📄
test_tuple.pyc
(2.21 KB)
📄
test_tuple.pyo
(2.21 KB)
📄
test_unicode.py
(4.58 KB)
📄
test_unicode.pyc
(6.57 KB)
📄
test_unicode.pyo
(6.57 KB)
Editing: test_decode.py
import decimal from unittest import TestCase from StringIO import StringIO import simplejson as json from simplejson import OrderedDict class TestDecode(TestCase): if not hasattr(TestCase, 'assertIs'): def assertIs(self, a, b): self.assertTrue(a is b, '%r is %r' % (a, b)) def test_decimal(self): rval = json.loads('1.1', parse_float=decimal.Decimal) self.assertTrue(isinstance(rval, decimal.Decimal)) self.assertEquals(rval, decimal.Decimal('1.1')) def test_float(self): rval = json.loads('1', parse_int=float) self.assertTrue(isinstance(rval, float)) self.assertEquals(rval, 1.0) def test_decoder_optimizations(self): # Several optimizations were made that skip over calls to # the whitespace regex, so this test is designed to try and # exercise the uncommon cases. The array cases are already covered. rval = json.loads('{ "key" : "value" , "k":"v" }') self.assertEquals(rval, {"key":"value", "k":"v"}) def test_empty_objects(self): s = '{}' self.assertEqual(json.loads(s), eval(s)) s = '[]' self.assertEqual(json.loads(s), eval(s)) s = '""' self.assertEqual(json.loads(s), eval(s)) def test_object_pairs_hook(self): s = '{"xkd":1, "kcw":2, "art":3, "hxm":4, "qrt":5, "pad":6, "hoy":7}' p = [("xkd", 1), ("kcw", 2), ("art", 3), ("hxm", 4), ("qrt", 5), ("pad", 6), ("hoy", 7)] self.assertEqual(json.loads(s), eval(s)) self.assertEqual(json.loads(s, object_pairs_hook=lambda x: x), p) self.assertEqual(json.load(StringIO(s), object_pairs_hook=lambda x: x), p) od = json.loads(s, object_pairs_hook=OrderedDict) self.assertEqual(od, OrderedDict(p)) self.assertEqual(type(od), OrderedDict) # the object_pairs_hook takes priority over the object_hook self.assertEqual(json.loads(s, object_pairs_hook=OrderedDict, object_hook=lambda x: None), OrderedDict(p)) def check_keys_reuse(self, source, loads): rval = loads(source) (a, b), (c, d) = sorted(rval[0]), sorted(rval[1]) self.assertIs(a, c) self.assertIs(b, d) def test_keys_reuse_str(self): s = u'[{"a_key": 1, "b_\xe9": 2}, {"a_key": 3, "b_\xe9": 4}]'.encode('utf8') self.check_keys_reuse(s, json.loads) def test_keys_reuse_unicode(self): s = u'[{"a_key": 1, "b_\xe9": 2}, {"a_key": 3, "b_\xe9": 4}]' self.check_keys_reuse(s, json.loads) def test_empty_strings(self): self.assertEqual(json.loads('""'), "") self.assertEqual(json.loads(u'""'), u"") self.assertEqual(json.loads('[""]'), [""]) self.assertEqual(json.loads(u'[""]'), [u""]) def test_raw_decode(self): cls = json.decoder.JSONDecoder self.assertEqual( ({'a': {}}, 9), cls().raw_decode("{\"a\": {}}")) # http://code.google.com/p/simplejson/issues/detail?id=85 self.assertEqual( ({'a': {}}, 9), cls(object_pairs_hook=dict).raw_decode("{\"a\": {}}"))
Upload File
Create Folder