added print_json

This commit is contained in:
Will McGugan 2021-08-28 15:04:06 +01:00
parent 69ea180f75
commit 6e76b2216f
11 changed files with 159 additions and 2 deletions

View file

@ -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(),