test fixes

This commit is contained in:
Will McGugan
2023-02-04 15:53:00 +01:00
parent fb7c1642bc
commit de2a4fd78d

View File

@@ -10,7 +10,7 @@ from textual.geometry import Region, Size
from textual.strip import Strip
def _extract_content(lines: list[list[Segment]]):
def _extract_content(lines: list[Strip]) -> list[str]:
"""Extract the text content from lines."""
content = ["".join(segment.text for segment in line) for line in lines]
return content
@@ -28,9 +28,9 @@ def test_set_dirty():
def test_no_styles():
"""Test that empty style returns the content un-altered"""
content = [
[Segment("foo")],
[Segment("bar")],
[Segment("baz")],
Strip([Segment("foo")]),
Strip([Segment("bar")]),
Strip([Segment("baz")]),
]
styles = Styles()
cache = StylesCache()
@@ -54,9 +54,9 @@ def test_no_styles():
def test_border():
content = [
[Segment("foo")],
[Segment("bar")],
[Segment("baz")],
Strip([Segment("foo")]),
Strip([Segment("bar")]),
Strip([Segment("baz")]),
]
styles = Styles()
styles.border = ("heavy", "white")
@@ -85,9 +85,9 @@ def test_border():
def test_padding():
content = [
[Segment("foo")],
[Segment("bar")],
[Segment("baz")],
Strip([Segment("foo")]),
Strip([Segment("bar")]),
Strip([Segment("baz")]),
]
styles = Styles()
styles.padding = 1
@@ -116,9 +116,9 @@ def test_padding():
def test_padding_border():
content = [
[Segment("foo")],
[Segment("bar")],
[Segment("baz")],
Strip([Segment("foo")]),
Strip([Segment("bar")]),
Strip([Segment("baz")]),
]
styles = Styles()
styles.padding = 1
@@ -150,9 +150,9 @@ def test_padding_border():
def test_outline():
content = [
[Segment("foo")],
[Segment("bar")],
[Segment("baz")],
Strip([Segment("foo")]),
Strip([Segment("bar")]),
Strip([Segment("baz")]),
]
styles = Styles()
styles.outline = ("heavy", "white")
@@ -177,9 +177,9 @@ def test_outline():
def test_crop():
content = [
[Segment("foo")],
[Segment("bar")],
[Segment("baz")],
Strip([Segment("foo")]),
Strip([Segment("bar")]),
Strip([Segment("baz")]),
]
styles = Styles()
styles.padding = 1
@@ -203,17 +203,17 @@ def test_crop():
assert text_content == expected_text
def test_dirty_cache():
def test_dirty_cache() -> None:
"""Check that we only render content once or if it has been marked as dirty."""
content = [
[Segment("foo")],
[Segment("bar")],
[Segment("baz")],
Strip([Segment("foo")]),
Strip([Segment("bar")]),
Strip([Segment("baz")]),
]
rendered_lines: list[int] = []
def get_content_line(y: int) -> list[Segment]:
def get_content_line(y: int) -> Strip:
rendered_lines.append(y)
return content[y]
@@ -232,6 +232,7 @@ def test_dirty_cache():
del rendered_lines[:]
text_content = _extract_content(lines)
print(text_content)
expected_text = [
"┏━━━━━┓",
"┃ ┃",