xonsh/tests/lib/test_jsonutils.py
Andy Kipp b9998ac5be
refactoring: move jsonutils to lib (#5548)
https://github.com/xonsh/xonsh/issues/5538

## For community
⬇️ **Please click the 👍 reaction instead of leaving a `+1` or 👍
comment**

Co-authored-by: a <1@1.1>
2024-06-29 00:46:04 +02:00

26 lines
537 B
Python

"""Testing xonsh json hooks"""
import json
import pytest
from xonsh.lib.jsonutils import serialize_xonsh_json
from xonsh.tools import EnvPath
@pytest.mark.parametrize(
"inp",
[
42,
"yo",
["hello"],
{"x": 65},
EnvPath(["wakka", "jawaka"]),
["y", EnvPath(["wakka", "jawaka"])],
{"z": EnvPath(["wakka", "jawaka"])},
],
)
def test_serialize_xonsh_json_roundtrip(inp):
s = json.dumps(inp, default=serialize_xonsh_json)
obs = json.loads(s)
assert inp == obs