rich/tests/test_rich_print.py

22 lines
428 B
Python
Raw Normal View History

2020-04-19 13:59:10 +00:00
import io
import rich
from rich.console import Console
2020-05-30 10:38:47 +00:00
def test_get_console():
console = rich.get_console()
assert isinstance(console, Console)
2020-04-19 13:59:10 +00:00
def test_rich_print():
2020-05-30 10:38:47 +00:00
console = rich.get_console()
2020-04-19 13:59:10 +00:00
output = io.StringIO()
2020-05-30 10:38:47 +00:00
backup_file = console.file
2020-04-19 13:59:10 +00:00
try:
2020-05-30 10:38:47 +00:00
console.file = output
2020-04-19 13:59:10 +00:00
rich.print("foo")
assert output.getvalue() == "foo\n"
finally:
2020-05-30 10:38:47 +00:00
console.file = backup_file