mirror of https://github.com/Textualize/rich.git
Values exceeding the console's width break print_json
This commit is contained in:
parent
9b42555e26
commit
316be7bf67
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue