mirror of https://github.com/Textualize/rich.git
Add `test_lines_justify`
This commit is contained in:
parent
d2d6f72413
commit
9f57640c48
|
@ -1,6 +1,7 @@
|
|||
from rich.console import Console
|
||||
from rich.containers import Lines, Renderables
|
||||
from rich.text import Text
|
||||
from rich.text import Span, Text
|
||||
from rich.style import Style
|
||||
|
||||
|
||||
def test_renderables_measure():
|
||||
|
@ -32,3 +33,24 @@ def test_lines_rich_console():
|
|||
|
||||
result = list(lines.__rich_console__(console, console.options))
|
||||
assert result == [Text("foo")]
|
||||
|
||||
|
||||
def test_lines_justify():
|
||||
console = Console()
|
||||
lines1 = Lines([Text("foo"), Text("test")])
|
||||
lines1.justify(console, 10, justify="left")
|
||||
assert lines1._lines == [Text("foo "), Text("test ")]
|
||||
lines1.justify(console, 10, justify="center")
|
||||
assert lines1._lines == [Text(" foo "), Text(" test ")]
|
||||
lines1.justify(console, 10, justify="right")
|
||||
assert lines1._lines == [Text(" foo"), Text(" test")]
|
||||
|
||||
lines2 = Lines([Text("foo bar"), Text("test")])
|
||||
lines2.justify(console, 7, justify="full")
|
||||
assert lines2._lines == [
|
||||
Text(
|
||||
"foo bar",
|
||||
spans=[Span(0, 3, ""), Span(3, 4, Style.parse("none")), Span(4, 7, "")],
|
||||
),
|
||||
Text("test"),
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue