def test_datetime(): data = { "dt": datetime.datetime(1970, 1, 1, 0, 0, 0, 1), } rj = RAPIDJSON.dumps(data) oj = ORJSON.dumps(data) sj = JSON_STDLIB.dumps(data) a = [rj, oj, sj] assert all(isinstance(el, str) for el in a) assert len(set(a)) == 1 rj_bin = RAPIDJSON.dumpb(data) oj_bin = ORJSON.dumpb(data) sj_bin = JSON_STDLIB.dumpb(data) b = [rj_bin, oj_bin, sj_bin] assert all(isinstance(el, bytes) for el in b)
def test_dump_numpy_array(): import numpy as np arr = np.array([[1, 2], [3, 4]]) rj = RAPIDJSON.dumps(arr) oj = ORJSON.dumps(arr) sj = JSON_STDLIB.dumps(arr) a = [rj, oj, sj] assert len(set(a)) == 1
def test_append_newline(): rj = RAPIDJSON.dumps(D, append_newline=True) oj = ORJSON.dumps(D, append_newline=True) sj = JSON_STDLIB.dumps(D, append_newline=True) a = [rj, oj, sj] assert len(set(a)) == 1
def test_pretty_sort_keys(): rj = RAPIDJSON.dumps(D, pretty=True, sort_keys=True) oj = ORJSON.dumps(D, pretty=True, sort_keys=True) sj = JSON_STDLIB.dumps(D, pretty=True, sort_keys=True) a = [rj, oj, sj] assert len(set(a)) == 1
def test_basic(): rj = RAPIDJSON.dumps(D) oj = ORJSON.dumps(D) sj = JSON_STDLIB.dumps(D) a = [rj, oj, sj] assert len(set(a)) == 1