rich/tests/test_json.py

9 lines
258 B
Python
Raw Normal View History

2021-10-06 04:50:47 +00:00
from rich.json import JSON
import datetime
def test_print_json_data_with_default():
date = datetime.date(2021, 1, 1)
json = JSON.from_data({"date": date}, default=lambda d: d.isoformat())
assert str(json.text) == '{\n "date": "2021-01-01"\n}'