File: test_styled.py

package info (click to toggle)
rich 13.9.4-1.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,284 kB
  • sloc: python: 29,157; makefile: 29
file content (15 lines) | stat: -rw-r--r-- 471 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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")
    console = Console(file=io.StringIO(), force_terminal=True, _environ={})
    assert Measurement.get(console, console.options, styled_foo) == Measurement(3, 3)
    console.print(styled_foo)
    result = console.file.getvalue()
    expected = "\x1b[41mfoo\x1b[0m\n"
    assert result == expected