summaryrefslogtreecommitdiffstats
path: root/tests/test_box.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 20:18:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 20:18:28 +0000
commitf8363b456f1ab31ee56abad579b215af195093d5 (patch)
treeb1500c675c2e0a55fb75721a854e1510acf7c862 /tests/test_box.py
parentInitial commit. (diff)
downloadrich-upstream.tar.xz
rich-upstream.zip
Adding upstream version 9.11.0.upstream/9.11.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/test_box.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/test_box.py b/tests/test_box.py
new file mode 100644
index 0000000..f235a82
--- /dev/null
+++ b/tests/test_box.py
@@ -0,0 +1,54 @@
+import pytest
+
+from rich.console import ConsoleOptions, ConsoleDimensions
+from rich.box import ASCII, DOUBLE, ROUNDED, HEAVY, SQUARE
+
+
+def test_str():
+ assert str(ASCII) == "+--+\n| ||\n|-+|\n| ||\n|-+|\n|-+|\n| ||\n+--+\n"
+
+
+def test_repr():
+ assert repr(ASCII) == "Box(...)"
+
+
+def test_get_top():
+ top = HEAVY.get_top(widths=[1, 2])
+ assert top == "┏━┳━━┓"
+
+
+def test_get_row():
+ head_row = DOUBLE.get_row(widths=[3, 2, 1], level="head")
+ assert head_row == "╠═══╬══╬═╣"
+
+ row = ASCII.get_row(widths=[1, 2, 3], level="row")
+ assert row == "|-+--+---|"
+
+ foot_row = ROUNDED.get_row(widths=[2, 1, 3], level="foot")
+ assert foot_row == "├──┼─┼───┤"
+
+ with pytest.raises(ValueError):
+ ROUNDED.get_row(widths=[1, 2, 3], level="FOO")
+
+
+def test_get_bottom():
+ bottom = HEAVY.get_bottom(widths=[1, 2, 3])
+ assert bottom == "┗━┻━━┻━━━┛"
+
+
+def test_box_substitute():
+ options = ConsoleOptions(
+ ConsoleDimensions(80, 25),
+ legacy_windows=True,
+ min_width=1,
+ max_width=100,
+ is_terminal=True,
+ encoding="utf-8",
+ )
+ assert HEAVY.substitute(options) == SQUARE
+
+ options.legacy_windows = False
+ assert HEAVY.substitute(options) == HEAVY
+
+ options.encoding = "ascii"
+ assert HEAVY.substitute(options) == ASCII