/opt/cloudlinux/venv/lib/python3.11/site-packages/simplejson/tests
NameSizeModeActions
__pycache__/-0755rm
test_bigint_as_string.py22380644editdlrm
test_bitsize_int_as_string.py22970644editdlrm
test_check_circular.py9170644editdlrm
test_decimal.py25440644editdlrm
test_decode.py51810644editdlrm
test_default.py2210644editdlrm
test_dump.py103560644editdlrm
test_encode_basestring_ascii.py23370644editdlrm
test_encode_for_html.py15150644editdlrm
test_errors.py20810644editdlrm
test_fail.py64540644editdlrm
test_float.py16760644editdlrm
test_for_json.py27670644editdlrm
test_indent.py25680644editdlrm
test_item_sort_key.py13760644editdlrm
test_iterable.py13900644editdlrm
test_namedtuple.py58960644editdlrm
test_pass1.py17460644editdlrm
test_pass2.py3860644editdlrm
test_pass3.py4820644editdlrm
test_raw_json.py10620644editdlrm
test_recursion.py16790644editdlrm
test_scanstring.py76480644editdlrm
test_separators.py9420644editdlrm
test_speedups.py41440644editdlrm
test_str_subclass.py7400644editdlrm
test_subclass.py11240644editdlrm
test_tool.py33040644editdlrm
test_tuple.py18310644editdlrm
test_unicode.py70560644editdlrm
_cibw_runner.py1730644editdlrm
__init__.py25120644editdlrm
Edit: /opt/cloudlinux/venv/lib/python3.11/site-packages/simplejson/tests/test_for_json.py (2767B)
import unittest import simplejson as json class ForJson(object): def for_json(self): return {'for_json': 1} class NestedForJson(object): def for_json(self): return {'nested': ForJson()} class ForJsonList(object): def for_json(self): return ['list'] class DictForJson(dict): def for_json(self): return {'alpha': 1} class ListForJson(list): def for_json(self): return ['list'] class TestForJson(unittest.TestCase): def assertRoundTrip(self, obj, other, for_json=True): if for_json is None: # None will use the default s = json.dumps(obj) else: s = json.dumps(obj, for_json=for_json) self.assertEqual( json.loads(s), other) def test_for_json_encodes_stand_alone_object(self): self.assertRoundTrip( ForJson(), ForJson().for_json()) def test_for_json_encodes_object_nested_in_dict(self): self.assertRoundTrip( {'hooray': ForJson()}, {'hooray': ForJson().for_json()}) def test_for_json_encodes_object_nested_in_list_within_dict(self): self.assertRoundTrip( {'list': [0, ForJson(), 2, 3]}, {'list': [0, ForJson().for_json(), 2, 3]}) def test_for_json_encodes_object_nested_within_object(self): self.assertRoundTrip( NestedForJson(), {'nested': {'for_json': 1}}) def test_for_json_encodes_list(self): self.assertRoundTrip( ForJsonList(), ForJsonList().for_json()) def test_for_json_encodes_list_within_object(self): self.assertRoundTrip( {'nested': ForJsonList()}, {'nested': ForJsonList().for_json()}) def test_for_json_encodes_dict_subclass(self): self.assertRoundTrip( DictForJson(a=1), DictForJson(a=1).for_json()) def test_for_json_encodes_list_subclass(self): self.assertRoundTrip( ListForJson(['l']), ListForJson(['l']).for_json()) def test_for_json_ignored_if_not_true_with_dict_subclass(self): for for_json in (None, False): self.assertRoundTrip( DictForJson(a=1), {'a': 1}, for_json=for_json) def test_for_json_ignored_if_not_true_with_list_subclass(self): for for_json in (None, False): self.assertRoundTrip( ListForJson(['l']), ['l'], for_json=for_json) def test_raises_typeerror_if_for_json_not_true_with_object(self): self.assertRaises(TypeError, json.dumps, ForJson()) self.assertRaises(TypeError, json.dumps, ForJson(), for_json=False)