xonsh/tests/test_jsonutils.py

27 lines
533 B
Python
Raw Normal View History

2017-02-26 15:42:36 -05:00
"""Testing xonsh json hooks"""
2017-02-26 15:42:36 -05:00
import json
import pytest
from xonsh.jsonutils import serialize_xonsh_json
2022-01-31 21:26:34 +05:30
from xonsh.tools import EnvPath
2017-02-26 15:42:36 -05:00
2018-08-30 09:18:49 -05:00
@pytest.mark.parametrize(
"inp",
[
42,
"yo",
["hello"],
{"x": 65},
EnvPath(["wakka", "jawaka"]),
["y", EnvPath(["wakka", "jawaka"])],
{"z": EnvPath(["wakka", "jawaka"])},
],
)
2017-02-26 15:42:36 -05:00
def test_serialize_xonsh_json_roundtrip(inp):
s = json.dumps(inp, default=serialize_xonsh_json)
obs = json.loads(s)
2018-08-30 09:18:49 -05:00
assert inp == obs