PATH:
opt
/
imunify360
/
venv
/
lib
/
python3.11
/
site-packages
/
simplejson
/
tests
from unittest import TestCase import simplejson as json from decimal import Decimal class AlternateInt(int): def __repr__(self): return 'invalid json' __str__ = __repr__ class AlternateFloat(float): def __repr__(self): return 'invalid json' __str__ = __repr__ # class AlternateDecimal(Decimal): # def __repr__(self): # return 'invalid json' class TestSubclass(TestCase): def test_int(self): self.assertEqual(json.dumps(AlternateInt(1)), '1') self.assertEqual(json.dumps(AlternateInt(-1)), '-1') self.assertEqual(json.loads(json.dumps({AlternateInt(1): 1})), {'1': 1}) def test_float(self): self.assertEqual(json.dumps(AlternateFloat(1.0)), '1.0') self.assertEqual(json.dumps(AlternateFloat(-1.0)), '-1.0') self.assertEqual(json.loads(json.dumps({AlternateFloat(1.0): 1})), {'1.0': 1}) # NOTE: Decimal subclasses are not supported as-is # def test_decimal(self): # self.assertEqual(json.dumps(AlternateDecimal('1.0')), '1.0') # self.assertEqual(json.dumps(AlternateDecimal('-1.0')), '-1.0')
[-] test_separators.py
[edit]
[-] test_speedups.py
[edit]
[-] test_namedtuple.py
[edit]
[-] test_indent.py
[edit]
[-] test_check_circular.py
[edit]
[-] test_decode.py
[edit]
[-] test_dump.py
[edit]
[-] test_raw_json.py
[edit]
[+]
..
[-] _cibw_runner.py
[edit]
[-] test_unicode.py
[edit]
[-] test_float.py
[edit]
[-] test_errors.py
[edit]
[-] test_encode_basestring_ascii.py
[edit]
[-] test_subclass.py
[edit]
[-] test_decimal.py
[edit]
[-] test_encode_for_html.py
[edit]
[-] test_default.py
[edit]
[-] test_iterable.py
[edit]
[-] test_fail.py
[edit]
[-] test_bitsize_int_as_string.py
[edit]
[-] test_tool.py
[edit]
[+]
__pycache__
[-] test_bigint_as_string.py
[edit]
[-] test_for_json.py
[edit]
[-] test_pass3.py
[edit]
[-] test_pass2.py
[edit]
[-] test_item_sort_key.py
[edit]
[-] __init__.py
[edit]
[-] test_str_subclass.py
[edit]
[-] test_scanstring.py
[edit]
[-] test_recursion.py
[edit]
[-] test_tuple.py
[edit]
[-] test_pass1.py
[edit]