1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
import pytest
from terminaltexteffects.utils import colorterm
pytestmark = [pytest.mark.utils, pytest.mark.smoke]
def test_fg_hex_with_hash():
assert colorterm.fg("#ffffff") == "\x1b[38;2;255;255;255m"
def test_fg_hex():
assert colorterm.fg("ffffff") == "\x1b[38;2;255;255;255m"
def test_fg_xterm():
assert colorterm.fg(255) == "\x1b[38;5;255m"
def test_fg_invalid_hex():
with pytest.raises(ValueError):
colorterm.fg("fgffff")
def test_fg_invalid_xterm():
with pytest.raises(ValueError):
colorterm.fg(256)
def test_fg_invalid_type():
with pytest.raises(TypeError):
colorterm.fg(3.14) # type: ignore[arg-type]
def test_bg_hex_with_hash():
assert colorterm.bg("#ffffff") == "\x1b[48;2;255;255;255m"
def test_bg_hex():
assert colorterm.bg("ffffff") == "\x1b[48;2;255;255;255m"
def test_bg_xterm():
assert colorterm.bg(255) == "\x1b[48;5;255m"
def test_bg_invalid_hex():
with pytest.raises(ValueError):
colorterm.bg("fgffff")
def test_bg_invalid_xterm():
with pytest.raises(ValueError):
colorterm.bg(256)
def test_bg_invalid_type():
with pytest.raises(TypeError):
colorterm.bg(3.14) # type: ignore[arg-type]
|