rich/tests/test_styled.py

16 lines
471 B
Python
Raw Normal View History

2020-07-02 19:00:33 +00:00
import io
from rich.console import Console
from rich.measure import Measurement
from rich.styled import Styled
def test_styled():
styled_foo = Styled("foo", "on red")
2021-03-01 19:42:00 +00:00
console = Console(file=io.StringIO(), force_terminal=True, _environ={})
2021-03-25 21:08:36 +00:00
assert Measurement.get(console, console.options, styled_foo) == Measurement(3, 3)
2020-07-02 19:00:33 +00:00
console.print(styled_foo)
result = console.file.getvalue()
expected = "\x1b[41mfoo\x1b[0m\n"
assert result == expected