This commit is contained in:
Will McGugan 2021-07-05 15:29:26 +01:00
parent 8105943b89
commit 8411f0021e
2 changed files with 51 additions and 56 deletions

View file

@ -59,7 +59,7 @@ def test_render_ascii():
@pytest.mark.skipif(sys.platform == "win32", reason="different on Windows")
def test_render():
def test_render_tree_non_win32():
tree = Tree("foo")
tree.add("bar", style="italic")
baz_tree = tree.add("baz", guide_style="bold red", style="on blue")
@ -76,6 +76,24 @@ def test_render():
assert result == expected
@pytest.mark.skipif(sys.platform != "win32", reason="Windows specific")
def test_render_tree_win32():
tree = Tree("foo")
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 = "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
def test_tree_measure():
tree = Tree("foo")
tree.add("bar")