console style

This commit is contained in:
Will McGugan 2020-12-17 17:05:37 +00:00
parent 0ea2d45a95
commit 7747025280
8 changed files with 106 additions and 22 deletions

View file

@ -7,20 +7,30 @@ from rich.color import (
ColorType,
ColorTriplet,
)
from rich import terminal_theme
from rich.style import Style
from rich.text import Text, Span
import pytest
def test_str() -> None:
assert str(Color.parse("red")) == "\x1b[31m⬤ \x1b[0m<color 'red' (standard)>"
assert str(Color.parse("red")) == "<color 'red' (standard)>"
def test_repr() -> None:
assert repr(Color.parse("red")) == "<color 'red' (standard)>"
def test_rich() -> None:
color = Color.parse("red")
as_text = color.__rich__()
print(repr(as_text))
print(repr(as_text.spans))
assert as_text == Text(
"<color 'red' (standard)⬤ >", spans=[Span(23, 24, Style(color=color))]
)
def test_system() -> None:
assert Color.parse("default").system == ColorSystem.STANDARD
assert Color.parse("red").system == ColorSystem.STANDARD