mirror of
https://github.com/Textualize/rich.git
synced 2025-07-24 12:53:58 +00:00
segment tests
This commit is contained in:
parent
57afd9303f
commit
ab0214ea53
2 changed files with 22 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
|||
from rich.segment import Segment
|
||||
from rich.style import Style
|
||||
|
||||
|
||||
def test_repr():
|
||||
|
@ -7,3 +8,22 @@ def test_repr():
|
|||
|
||||
def test_line():
|
||||
assert Segment.line() == Segment("\n")
|
||||
|
||||
|
||||
def test_apply_style():
|
||||
segments = [Segment("foo"), Segment("bar", Style(bold=True))]
|
||||
assert Segment.apply_style(segments, None) is segments
|
||||
assert list(Segment.apply_style(segments, Style(italic=True))) == [
|
||||
Segment("foo", Style(italic=True)),
|
||||
Segment("bar", Style(italic=True, bold=True)),
|
||||
]
|
||||
|
||||
|
||||
def test_split_and_crop_lines():
|
||||
assert list(
|
||||
Segment.split_and_crop_lines([Segment("Hello\nWorld!\n"), Segment("foo")], 4)
|
||||
) == [[Segment("Hell")], [Segment("Worl")], [Segment("foo")]]
|
||||
|
||||
|
||||
def test_get_line_length():
|
||||
assert Segment.get_line_length([Segment("foo"), Segment("bar")]) == 6
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue