mirror of https://github.com/Textualize/rich.git
test method for render_group fitting
This commit is contained in:
parent
e906e9a648
commit
7e9cff8bed
|
@ -8,7 +8,8 @@ import pytest
|
||||||
|
|
||||||
from rich import errors
|
from rich import errors
|
||||||
from rich.color import ColorSystem
|
from rich.color import ColorSystem
|
||||||
from rich.console import CaptureError, Console, ConsoleOptions
|
from rich.console import CaptureError, Console, ConsoleOptions, render_group
|
||||||
|
from rich.measure import measure_renderables
|
||||||
from rich.pager import SystemPager
|
from rich.pager import SystemPager
|
||||||
from rich.panel import Panel
|
from rich.panel import Panel
|
||||||
from rich.style import Style
|
from rich.style import Style
|
||||||
|
@ -377,3 +378,19 @@ def test_out() -> None:
|
||||||
console.begin_capture()
|
console.begin_capture()
|
||||||
console.out(*(["foo bar"] * 5), sep=".", end="X")
|
console.out(*(["foo bar"] * 5), sep=".", end="X")
|
||||||
assert console.end_capture() == "foo bar.foo bar.foo bar.foo bar.foo barX"
|
assert console.end_capture() == "foo bar.foo bar.foo bar.foo bar.foo barX"
|
||||||
|
|
||||||
|
|
||||||
|
def test_render_group_fit() -> None:
|
||||||
|
@render_group()
|
||||||
|
def renderable():
|
||||||
|
yield "one"
|
||||||
|
yield "two"
|
||||||
|
yield "three" # <- largest width of 5
|
||||||
|
yield "four"
|
||||||
|
|
||||||
|
renderables = [renderable() for _ in range(4)]
|
||||||
|
|
||||||
|
console = Console(width=42)
|
||||||
|
|
||||||
|
min_width, _ = measure_renderables(console, renderables, 42)
|
||||||
|
assert min_width == 5
|
||||||
|
|
Loading…
Reference in New Issue