mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
fix test
This commit is contained in:
@@ -12,9 +12,10 @@ def test_line_crop():
|
||||
Segment("Hello", bold),
|
||||
Segment(" World!", italic),
|
||||
]
|
||||
total = sum(segment.cell_length for segment in segments)
|
||||
|
||||
assert line_crop(segments, 1, 2) == [Segment("e", bold)]
|
||||
assert line_crop(segments, 4, 20) == [
|
||||
assert line_crop(segments, 1, 2, total) == [Segment("e", bold)]
|
||||
assert line_crop(segments, 4, 20, total) == [
|
||||
Segment("o", bold),
|
||||
Segment(" World!", italic),
|
||||
]
|
||||
@@ -27,16 +28,23 @@ def test_line_crop_emoji():
|
||||
Segment("Hello", bold),
|
||||
Segment("💩💩💩", italic),
|
||||
]
|
||||
assert line_crop(segments, 8, 11) == [Segment(" 💩", italic)]
|
||||
assert line_crop(segments, 9, 11) == [Segment("💩", italic)]
|
||||
total = sum(segment.cell_length for segment in segments)
|
||||
assert line_crop(segments, 8, 11, total) == [Segment(" 💩", italic)]
|
||||
assert line_crop(segments, 9, 11, total) == [Segment("💩", italic)]
|
||||
|
||||
|
||||
def test_line_crop_edge():
|
||||
segments = [Segment("foo"), Segment("bar"), Segment("baz")]
|
||||
assert line_crop(segments, 2, 9) == [Segment("o"), Segment("bar"), Segment("baz")]
|
||||
assert line_crop(segments, 3, 9) == [Segment("bar"), Segment("baz")]
|
||||
assert line_crop(segments, 4, 9) == [Segment("ar"), Segment("baz")]
|
||||
assert line_crop(segments, 4, 8) == [Segment("ar"), Segment("ba")]
|
||||
total = sum(segment.cell_length for segment in segments)
|
||||
|
||||
assert line_crop(segments, 2, 9, total) == [
|
||||
Segment("o"),
|
||||
Segment("bar"),
|
||||
Segment("baz"),
|
||||
]
|
||||
assert line_crop(segments, 3, 9, total) == [Segment("bar"), Segment("baz")]
|
||||
assert line_crop(segments, 4, 9, total) == [Segment("ar"), Segment("baz")]
|
||||
assert line_crop(segments, 4, 8, total) == [Segment("ar"), Segment("ba")]
|
||||
|
||||
|
||||
def test_line_crop_edge_2():
|
||||
@@ -49,7 +57,8 @@ def test_line_crop_edge_2():
|
||||
"─╮",
|
||||
),
|
||||
]
|
||||
result = line_crop(segments, 30, 60)
|
||||
total = sum(segment.cell_length for segment in segments)
|
||||
result = line_crop(segments, 30, 60, total)
|
||||
expected = []
|
||||
print(repr(result))
|
||||
assert result == expected
|
||||
|
||||
Reference in New Issue
Block a user