mirror of
https://github.com/Textualize/rich.git
synced 2025-08-04 18:18:22 +00:00
tests(tree): add tree render with hide_root flag
This commit is contained in:
parent
1015379fe3
commit
f2a8a0ebc8
1 changed files with 33 additions and 0 deletions
|
@ -93,6 +93,39 @@ def test_render_tree_win32():
|
|||
expected = "foo \n├── \x1b[3mbar\x1b[0m\x1b[3m \x1b[0m\n\x1b[44m├── \x1b[0m\x1b[44mbaz\x1b[0m\x1b[44m \x1b[0m\n\x1b[44m│ \x1b[0m\x1b[31;44m├── \x1b[0m\x1b[44m1\x1b[0m\x1b[44m \x1b[0m\n\x1b[44m│ \x1b[0m\x1b[31;44m└── \x1b[0m\x1b[44m2\x1b[0m\x1b[44m \x1b[0m\n└── egg \n"
|
||||
assert result == expected
|
||||
|
||||
@pytest.mark.skipif(sys.platform == "win32", reason="different on Windows")
|
||||
def test_render_tree_hide_root_non_win32():
|
||||
tree = Tree("foo", hide_root=True)
|
||||
tree.add("bar", style="italic")
|
||||
baz_tree = tree.add("baz", guide_style="bold red", style="on blue")
|
||||
baz_tree.add("1")
|
||||
baz_tree.add("2")
|
||||
tree.add("egg")
|
||||
|
||||
console = Console(width=20, force_terminal=True, color_system="standard")
|
||||
console.begin_capture()
|
||||
console.print(tree)
|
||||
result = console.end_capture()
|
||||
print(repr(result))
|
||||
expected = "\x1b[3mbar\x1b[0m\x1b[3m \x1b[0m\n\x1b[44mbaz\x1b[0m\x1b[44m \x1b[0m\n\x1b[31;44m┣━━ \x1b[0m\x1b[44m1\x1b[0m\x1b[44m \x1b[0m\n\x1b[31;44m┗━━ \x1b[0m\x1b[44m2\x1b[0m\x1b[44m \x1b[0m\negg \n"
|
||||
assert result == expected
|
||||
|
||||
@pytest.mark.skipif(sys.platform != "win32", reason="Windows specific")
|
||||
def test_render_tree_hide_root_win32():
|
||||
tree = Tree("foo", hide_root=True)
|
||||
tree.add("bar", style="italic")
|
||||
baz_tree = tree.add("baz", guide_style="bold red", style="on blue")
|
||||
baz_tree.add("1")
|
||||
baz_tree.add("2")
|
||||
tree.add("egg")
|
||||
|
||||
console = Console(width=20, force_terminal=True, color_system="standard")
|
||||
console.begin_capture()
|
||||
console.print(tree)
|
||||
result = console.end_capture()
|
||||
print(repr(result))
|
||||
expected = "\x1b[3mbar\x1b[0m\x1b[3m \x1b[0m\n\x1b[44mbaz\x1b[0m\x1b[44m \x1b[0m\n\x1b[31;44m├── \x1b[0m\x1b[44m1\x1b[0m\x1b[44m \x1b[0m\n\x1b[31;44m└── \x1b[0m\x1b[44m2\x1b[0m\x1b[44m \x1b[0m\negg \n"
|
||||
assert result == expected
|
||||
|
||||
def test_tree_measure():
|
||||
tree = Tree("foo")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue