mirror of
https://github.com/Textualize/rich.git
synced 2025-08-10 21:18:08 +00:00
added print_json
This commit is contained in:
parent
69ea180f75
commit
6e76b2216f
11 changed files with 159 additions and 2 deletions
|
@ -117,6 +117,15 @@ def test_print():
|
|||
assert console.file.getvalue() == "foo\n"
|
||||
|
||||
|
||||
def test_print_json():
|
||||
console = Console(file=io.StringIO(), color_system="truecolor")
|
||||
console.print_json('[false, true, null, "foo"]')
|
||||
result = console.file.getvalue()
|
||||
print(repr(result))
|
||||
expected = '\x1b[1m[\x1b[0m\n \x1b[3;91mfalse\x1b[0m,\n \x1b[3;92mtrue\x1b[0m,\n \x1b[3;35mnull\x1b[0m,\n \x1b[32m"foo"\x1b[0m\n\x1b[1m]\x1b[0m\n'
|
||||
assert result == expected
|
||||
|
||||
|
||||
def test_log():
|
||||
console = Console(
|
||||
file=io.StringIO(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue