improving test_box_substitute to cover more inputs of substitute()

This commit is contained in:
Andre Hora 2023-01-30 15:38:10 -03:00
parent b89d0362e8
commit f65770dd0d
1 changed files with 32 additions and 1 deletions

View File

@ -1,7 +1,19 @@
import pytest
from rich.console import ConsoleOptions, ConsoleDimensions
from rich.box import ASCII, DOUBLE, ROUNDED, HEAVY, SQUARE
from rich.box import (
ASCII,
DOUBLE,
ROUNDED,
HEAVY,
SQUARE,
MINIMAL_HEAVY_HEAD,
MINIMAL,
SIMPLE_HEAVY,
SIMPLE,
HEAVY_EDGE,
HEAVY_HEAD,
)
def test_str():
@ -46,10 +58,29 @@ def test_box_substitute():
encoding="utf-8",
max_height=25,
)
# A different Box due to legacy_windows
assert ROUNDED.substitute(options) == SQUARE
assert MINIMAL_HEAVY_HEAD.substitute(options) == MINIMAL
assert SIMPLE_HEAVY.substitute(options) == SIMPLE
assert HEAVY.substitute(options) == SQUARE
assert HEAVY_EDGE.substitute(options) == SQUARE
assert HEAVY_HEAD.substitute(options) == SQUARE
# The same box
options.legacy_windows = False
assert ROUNDED.substitute(options) == ROUNDED
assert MINIMAL_HEAVY_HEAD.substitute(options) == MINIMAL_HEAVY_HEAD
assert SIMPLE_HEAVY.substitute(options) == SIMPLE_HEAVY
assert HEAVY.substitute(options) == HEAVY
assert HEAVY_EDGE.substitute(options) == HEAVY_EDGE
assert HEAVY_HEAD.substitute(options) == HEAVY_HEAD
# A different Box due to ascii encoding
options.encoding = "ascii"
assert ROUNDED.substitute(options) == ASCII
assert MINIMAL_HEAVY_HEAD.substitute(options) == ASCII
assert SIMPLE_HEAVY.substitute(options) == ASCII
assert HEAVY.substitute(options) == ASCII
assert HEAVY_EDGE.substitute(options) == ASCII
assert HEAVY_HEAD.substitute(options) == ASCII