diff --git a/tests/test_rich_print.py b/tests/test_rich_print.py index f6ea5110..a92b8000 100644 --- a/tests/test_rich_print.py +++ b/tests/test_rich_print.py @@ -1,4 +1,5 @@ import io +import json import rich from rich.console import Console @@ -38,6 +39,27 @@ def test_rich_print_json(): assert result == expected +def test_rich_print_json_round_trip(): + data = ["x" * 100, 2e128] + console = rich.get_console() + with console.capture() as capture: + rich.print_json(data=data, indent=4) + result = capture.get() + print(repr(result)) + result_data = json.loads(result) + assert result_data == data + + +def test_rich_print_json_no_truncation(): + console = rich.get_console() + with console.capture() as capture: + rich.print_json(f'["{"x" * 100}", {int(2e128)}]', indent=4) + result = capture.get() + print(repr(result)) + assert ("x" * 100) in result + assert str(int(2e128)) in result + + def test_rich_print_X(): console = rich.get_console() output = io.StringIO()