rich/tests/test_status.py

36 lines
1019 B
Python
Raw Normal View History

2020-12-10 17:07:11 +00:00
from time import sleep
from rich.console import Console
from rich.spinner import Spinner
2020-12-10 17:07:11 +00:00
from rich.status import Status
def test_status():
console = Console(
color_system=None, width=80, legacy_windows=False, get_time=lambda: 0.0
)
status = Status("foo", console=console)
assert status.console == console
2021-03-29 01:41:56 +00:00
previous_status_renderable = status.renderable
status.update(status="bar", spinner_style="red", speed=2.0)
2020-12-10 17:07:11 +00:00
2021-03-29 01:41:56 +00:00
assert previous_status_renderable == status.renderable
assert isinstance(status.renderable, Spinner)
2021-03-29 01:41:56 +00:00
status.update(spinner="dots2")
assert previous_status_renderable != status.renderable
2020-12-10 17:07:11 +00:00
# TODO: Testing output is tricky with threads
with status:
sleep(0.2)
2021-02-06 11:49:54 +00:00
def test_renderable():
console = Console(
color_system=None, width=80, legacy_windows=False, get_time=lambda: 0.0
)
status = Status("foo", console=console)
console.begin_capture()
console.print(status)
assert console.end_capture() == "⠋ foo\n"