mirror of https://github.com/Textualize/rich.git
simpler test
This commit is contained in:
parent
742db22bdd
commit
5ea5e1d5bd
|
@ -5,16 +5,7 @@ from rich.console import Console
|
||||||
from render import render
|
from render import render
|
||||||
|
|
||||||
|
|
||||||
test_data = [
|
test_data = [1, 2, 3]
|
||||||
{
|
|
||||||
"jsonrpc": "2.0",
|
|
||||||
"method": "sum",
|
|
||||||
"params": [None, 1, 2, 4, False, True],
|
|
||||||
"id": "1",
|
|
||||||
},
|
|
||||||
{"jsonrpc": "2.0", "method": "notify_hello", "params": [7]},
|
|
||||||
{"jsonrpc": "2.0", "method": "subtract", "params": [42, 23], "id": "2"},
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def render_log():
|
def render_log():
|
||||||
|
@ -25,11 +16,6 @@ def render_log():
|
||||||
log_time_format="[TIME] ",
|
log_time_format="[TIME] ",
|
||||||
color_system="truecolor",
|
color_system="truecolor",
|
||||||
)
|
)
|
||||||
enabled = False
|
|
||||||
context = {
|
|
||||||
"foo": "bar",
|
|
||||||
}
|
|
||||||
movies = ["Deadpool", "Rise of the Skywalker"]
|
|
||||||
console.log()
|
console.log()
|
||||||
console.log("Hello from", console, "!")
|
console.log("Hello from", console, "!")
|
||||||
console.log(test_data, log_locals=True)
|
console.log(test_data, log_locals=True)
|
||||||
|
@ -37,7 +23,7 @@ def render_log():
|
||||||
|
|
||||||
|
|
||||||
def test_log():
|
def test_log():
|
||||||
expected = "\n\x1b[2;36m[TIME] \x1b[0mHello from \x1b[1m<\x1b[0m\x1b[1;38;5;13mconsole\x1b[0m\x1b[39m \x1b[0m\x1b[3;33mwidth\x1b[0m\x1b[39m=\x1b[0m\x1b[1;34m80\x1b[0m\x1b[39m ColorSystem.TRUECOLOR\x1b[0m\x1b[1m>\x1b[0m ! \x1b[2mtest_log.py:34\x1b[0m\n\x1b[2;36m \x1b[0m\x1b[1m[\x1b[0m \x1b[2mtest_log.py:35\x1b[0m\n \x1b[1m{\x1b[0m \n \x1b[32m'id'\x1b[0m: \x1b[32m'\x1b[0m\x1b[32m1\x1b[0m\x1b[32m'\x1b[0m, \n \x1b[32m'jsonrpc'\x1b[0m: \x1b[32m'\x1b[0m\x1b[32m2.0\x1b[0m\x1b[32m'\x1b[0m, \n \x1b[32m'method'\x1b[0m: \x1b[32m'sum'\x1b[0m, \n \x1b[32m'params'\x1b[0m: \x1b[1m[\x1b[0m\x1b[3;35mNone\x1b[0m, \x1b[1;34m1\x1b[0m, \x1b[1;34m2\x1b[0m, \x1b[1;34m4\x1b[0m, \x1b[3;38;5;9mFalse\x1b[0m, \x1b[3;38;5;10mTrue\x1b[0m\x1b[1m]\x1b[0m, \n \x1b[1m}\x1b[0m, \n \x1b[1m{\x1b[0m \n \x1b[32m'jsonrpc'\x1b[0m: \x1b[32m'\x1b[0m\x1b[32m2.0\x1b[0m\x1b[32m'\x1b[0m, \n \x1b[32m'method'\x1b[0m: \x1b[32m'notify_hello'\x1b[0m, \n \x1b[32m'params'\x1b[0m: \x1b[1m[\x1b[0m\x1b[1;34m7\x1b[0m\x1b[1m]\x1b[0m, \n \x1b[1m}\x1b[0m, \n \x1b[1m{\x1b[0m \n \x1b[32m'id'\x1b[0m: \x1b[32m'\x1b[0m\x1b[32m2\x1b[0m\x1b[32m'\x1b[0m, \n \x1b[32m'jsonrpc'\x1b[0m: \x1b[32m'\x1b[0m\x1b[32m2.0\x1b[0m\x1b[32m'\x1b[0m, \n \x1b[32m'method'\x1b[0m: \x1b[32m'subtract'\x1b[0m, \n \x1b[32m'params'\x1b[0m: \x1b[1m[\x1b[0m\x1b[1;34m42\x1b[0m, \x1b[1;34m23\x1b[0m\x1b[1m]\x1b[0m, \n \x1b[1m}\x1b[0m, \n \x1b[1m]\x1b[0m \n \x1b[3m Locals \x1b[0m \n \x1b[34m╭─────────┬────────────────────────────────────────╮\x1b[0m \n \x1b[34m│\x1b[0m\x1b[32m'console'\x1b[0m\x1b[34m│\x1b[0m\x1b[1m<\x1b[0m\x1b[1;38;5;13mconsole\x1b[0m\x1b[39m \x1b[0m\x1b[3;33mwidth\x1b[0m\x1b[39m=\x1b[0m\x1b[1;34m80\x1b[0m\x1b[39m ColorSystem.TRUECOLOR\x1b[0m\x1b[1m>\x1b[0m\x1b[34m│\x1b[0m \n \x1b[34m│\x1b[0m\x1b[32m'enabled'\x1b[0m\x1b[34m│\x1b[0m\x1b[3;38;5;9mFalse\x1b[0m \x1b[34m│\x1b[0m \n \x1b[34m│\x1b[0m\x1b[32m'context'\x1b[0m\x1b[34m│\x1b[0m\x1b[1m{\x1b[0m\x1b[32m'foo'\x1b[0m: \x1b[32m'bar'\x1b[0m\x1b[1m}\x1b[0m \x1b[34m│\x1b[0m \n \x1b[34m│\x1b[0m\x1b[32m'movies'\x1b[0m \x1b[34m│\x1b[0m\x1b[1m[\x1b[0m\x1b[32m'Deadpool'\x1b[0m, \x1b[32m'Rise of the Skywalker'\x1b[0m\x1b[1m]\x1b[0m \x1b[34m│\x1b[0m \n \x1b[34m╰─────────┴────────────────────────────────────────╯\x1b[0m \n"
|
expected = "\n\x1b[2;36m[TIME] \x1b[0mHello from \x1b[1m<\x1b[0m\x1b[1;38;5;13mconsole\x1b[0m\x1b[39m \x1b[0m\x1b[3;33mwidth\x1b[0m\x1b[39m=\x1b[0m\x1b[1;34m80\x1b[0m\x1b[39m ColorSystem.TRUECOLOR\x1b[0m\x1b[1m>\x1b[0m ! \x1b[2mtest_log.py:20\x1b[0m\n\x1b[2;36m \x1b[0m\x1b[1m[\x1b[0m\x1b[1;34m1\x1b[0m, \x1b[1;34m2\x1b[0m, \x1b[1;34m3\x1b[0m\x1b[1m]\x1b[0m \x1b[2mtest_log.py:21\x1b[0m\n \x1b[3m Locals \x1b[0m \n \x1b[34m╭─────────┬────────────────────────────────────────╮\x1b[0m \n \x1b[34m│\x1b[0m\x1b[32m'console'\x1b[0m\x1b[34m│\x1b[0m\x1b[1m<\x1b[0m\x1b[1;38;5;13mconsole\x1b[0m\x1b[39m \x1b[0m\x1b[3;33mwidth\x1b[0m\x1b[39m=\x1b[0m\x1b[1;34m80\x1b[0m\x1b[39m ColorSystem.TRUECOLOR\x1b[0m\x1b[1m>\x1b[0m\x1b[34m│\x1b[0m \n \x1b[34m╰─────────┴────────────────────────────────────────╯\x1b[0m \n"
|
||||||
assert render_log() == expected
|
assert render_log() == expected
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue