def test_nested_dict(): obj = { 5: { 'a': 3 }, 'b': { 'c': { 3: 5 } }, True: False, None: [1, 2, 3, 4, 5], } assert dumps(obj) == \ json.dumps(obj)
def test_none(): assert dumps(None) == 'null'
def test_infinity(): with pytest.raises(ValueError): dumps(float('inf'))
def test_wrong_type(): with pytest.raises(TypeError): dumps(...)
def test_nested_dict(): assert dumps({5: {'a': 3}, 'b': {'c': 4}}) == \ '{"5": {"a": 3}, "b": {"c": 4}}'
def test_dict(): assert dumps({1: 'a', 'abc': None}) == '{"1": "a", "abc": null}'
def test_list(): assert dumps([1, 2, True, None]) == '[1, 2, true, null]'
def test_bool(): assert dumps(True) == json.dumps(True)
def test_string(): assert dumps('string') == '"string"'
def test_number(): assert dumps(123) == json.dumps(123)
def test_none(): assert dumps(None) == json.dumps(None)
def test_dict(): assert dumps({1: 'a', 'abc': None}) == json.dumps({1: 'a', 'abc': None})
def test_list(): assert dumps([1, 2, True, None]) == json.dumps([1, 2, True, None])
def test_nan(): with pytest.raises(ValueError): dumps(float('nan'))
def test_bool(): assert dumps(True) == 'true'
def test_number(): assert dumps(123) == '123'
def test_string(): assert dumps('string') == json.dumps('string')