This commit is contained in:
Will McGugan 2021-06-18 20:37:33 +01:00
parent 56b4c53274
commit 6e97016e22
3 changed files with 19 additions and 1 deletions

View File

@ -21,6 +21,10 @@ def test_repr() -> None:
assert repr(Color.parse("red")) == "Color('red', ColorType.STANDARD, number=1)" assert repr(Color.parse("red")) == "Color('red', ColorType.STANDARD, number=1)"
def test_color_system_repr() -> None:
assert repr(ColorSystem.EIGHT_BIT) == "ColorSystem.EIGHT_BIT"
def test_rich() -> None: def test_rich() -> None:
color = Color.parse("red") color = Color.parse("red")
as_text = color.__rich__() as_text = color.__rich__()

View File

@ -149,3 +149,17 @@ def test_escape_escape():
result = render(r"\\\\") result = render(r"\\\\")
assert str(result) == r"\\\\" assert str(result) == r"\\\\"
def test_events():
result = render("[@click]Hello[/@click] [@click='view.toggle', 'left']World[/]")
assert str(result) == "Hello World"
def test_events_broken():
with pytest.raises(MarkupError):
render("[@click=sdfwer]foo[/]")
with pytest.raises(MarkupError):
render("[@click='view.toggle]foo[/]")

View File

@ -21,7 +21,7 @@ class Foo:
@rich.repr.auto @rich.repr.auto
class Egg: class Egg:
def __init__(self, foo: str, /, bar: Optional[int] = None, egg: int = 1): def __init__(self, foo: str, bar: Optional[int] = None, egg: int = 1):
self.foo = foo self.foo = foo
self.bar = bar self.bar = bar
self.egg = egg self.egg = egg