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_decimal.py
from decimal import Decimal from unittest import TestCase from StringIO import StringIO import simplejson as json class TestDecimal(TestCase): NUMS = "1.0", "10.00", "1.1", "1234567890.1234567890", "500" def dumps(self, obj, **kw): sio = StringIO() json.dump(obj, sio, **kw) res = json.dumps(obj, **kw) self.assertEquals(res, sio.getvalue()) return res def loads(self, s, **kw): sio = StringIO(s) res = json.loads(s, **kw) self.assertEquals(res, json.load(sio, **kw)) return res def test_decimal_encode(self): for d in map(Decimal, self.NUMS): self.assertEquals(self.dumps(d, use_decimal=True), str(d)) def test_decimal_decode(self): for s in self.NUMS: self.assertEquals(self.loads(s, parse_float=Decimal), Decimal(s)) def test_decimal_roundtrip(self): for d in map(Decimal, self.NUMS): # The type might not be the same (int and Decimal) but they # should still compare equal. self.assertEquals( self.loads( self.dumps(d, use_decimal=True), parse_float=Decimal), d) self.assertEquals( self.loads( self.dumps([d], use_decimal=True), parse_float=Decimal), [d]) def test_decimal_defaults(self): d = Decimal('1.1') # use_decimal=True is the default self.assertRaises(TypeError, json.dumps, d, use_decimal=False) self.assertEqual('1.1', json.dumps(d)) self.assertEqual('1.1', json.dumps(d, use_decimal=True)) self.assertRaises(TypeError, json.dump, d, StringIO(), use_decimal=False) sio = StringIO() json.dump(d, sio) self.assertEqual('1.1', sio.getvalue()) sio = StringIO() json.dump(d, sio, use_decimal=True) self.assertEqual('1.1', sio.getvalue())
Upload File
Create Folder