rich/tests/test_protocol.py

17 lines
286 B
Python
Raw Normal View History

2020-04-27 15:22:39 +00:00
import io
from rich.console import Console
from rich.text import Text
class Foo:
def __rich__(self):
return Text("Foo")
def test_rich_case():
foo = Foo()
console = Console(file=io.StringIO())
console.print(foo)
assert console.file.getvalue() == "Foo\n"