mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
fix test
This commit is contained in:
@@ -104,7 +104,7 @@ Tweet {
|
|||||||
|
|
||||||
.code {
|
.code {
|
||||||
|
|
||||||
height: 34;
|
height: auto;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,7 +109,10 @@ class BasicApp(App, css_path="basic.css"):
|
|||||||
content=Widget(
|
content=Widget(
|
||||||
Tweet(TweetBody()),
|
Tweet(TweetBody()),
|
||||||
Widget(
|
Widget(
|
||||||
Static(Syntax(CODE, "python"), classes="code"),
|
Static(
|
||||||
|
Syntax(CODE, "python", line_numbers=True, indent_guides=True),
|
||||||
|
classes="code",
|
||||||
|
),
|
||||||
classes="scrollable",
|
classes="scrollable",
|
||||||
),
|
),
|
||||||
Error(),
|
Error(),
|
||||||
|
|||||||
@@ -72,9 +72,10 @@ class Widget(DOMNode):
|
|||||||
scrollbar-background: $panel-darken-2;
|
scrollbar-background: $panel-darken-2;
|
||||||
scrollbar-background-hover: $panel-darken-3;
|
scrollbar-background-hover: $panel-darken-3;
|
||||||
scrollbar-color: $system;
|
scrollbar-color: $system;
|
||||||
scrollbar-color-active: $accent-darken-1;
|
scrollbar-color-active: $accent-darken-1;
|
||||||
scrollbar-size-vertical: 2;
|
scrollbar-size-vertical: 2;
|
||||||
scrollbar-size-horizontal: 1;
|
scrollbar-size-horizontal: 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,10 @@ def test_line_crop():
|
|||||||
Segment("Hello", bold),
|
Segment("Hello", bold),
|
||||||
Segment(" World!", italic),
|
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, 1, 2, total) == [Segment("e", bold)]
|
||||||
assert line_crop(segments, 4, 20) == [
|
assert line_crop(segments, 4, 20, total) == [
|
||||||
Segment("o", bold),
|
Segment("o", bold),
|
||||||
Segment(" World!", italic),
|
Segment(" World!", italic),
|
||||||
]
|
]
|
||||||
@@ -27,16 +28,23 @@ def test_line_crop_emoji():
|
|||||||
Segment("Hello", bold),
|
Segment("Hello", bold),
|
||||||
Segment("💩💩💩", italic),
|
Segment("💩💩💩", italic),
|
||||||
]
|
]
|
||||||
assert line_crop(segments, 8, 11) == [Segment(" 💩", italic)]
|
total = sum(segment.cell_length for segment in segments)
|
||||||
assert line_crop(segments, 9, 11) == [Segment("💩", italic)]
|
assert line_crop(segments, 8, 11, total) == [Segment(" 💩", italic)]
|
||||||
|
assert line_crop(segments, 9, 11, total) == [Segment("💩", italic)]
|
||||||
|
|
||||||
|
|
||||||
def test_line_crop_edge():
|
def test_line_crop_edge():
|
||||||
segments = [Segment("foo"), Segment("bar"), Segment("baz")]
|
segments = [Segment("foo"), Segment("bar"), Segment("baz")]
|
||||||
assert line_crop(segments, 2, 9) == [Segment("o"), Segment("bar"), Segment("baz")]
|
total = sum(segment.cell_length for segment in segments)
|
||||||
assert line_crop(segments, 3, 9) == [Segment("bar"), Segment("baz")]
|
|
||||||
assert line_crop(segments, 4, 9) == [Segment("ar"), Segment("baz")]
|
assert line_crop(segments, 2, 9, total) == [
|
||||||
assert line_crop(segments, 4, 8) == [Segment("ar"), Segment("ba")]
|
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():
|
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 = []
|
expected = []
|
||||||
print(repr(result))
|
print(repr(result))
|
||||||
assert result == expected
|
assert result == expected
|
||||||
|
|||||||
Reference in New Issue
Block a user