Coverage for tests/unit_tests/common/test_apio_console.py: 100%
14 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-06 10:20 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-06 10:20 +0000
1"""Test for the apio_console.py."""
3from apio.common import apio_console
4from apio.common.apio_console import (
5 FORCE_TERMINAL,
6 cstyle,
7 cunstyle,
8)
11def test_style_unstyle():
12 """Test the styling and unstyling functions"""
14 apio_console.configure(terminal_mode=FORCE_TERMINAL, theme_name="light")
16 # -- Test cstyle()
17 assert cstyle("") == ""
18 assert cstyle("", style="red") == ""
19 assert cstyle("abc xyz", style="red") == "\x1b[31mabc xyz\x1b[0m"
20 assert cstyle("abc xyz", style="cyan bold") == "\x1b[1;36mabc xyz\x1b[0m"
21 assert cstyle("ab \n xy", style="cyan bold") == "\x1b[1;36mab \n xy\x1b[0m"
23 # -- Test cunstyle() with plain text.
24 assert cunstyle("") == ""
25 assert cunstyle("abc xyz") == "abc xyz"
27 # -- Test cunstyle() with colored text.
28 assert cunstyle(cstyle("")) == ""
29 assert cunstyle(cstyle("abc xyz")) == "abc xyz"
30 assert cunstyle(cstyle("ab \n xy")) == "ab \n xy"