Пример #1
0
def test_colorize_with_two_colors():
    text = "test string <c1>with</c1> one <c2>color</c2> placeholders"
    assert (
        colorize(text, 2, ["red", "red"]) ==
        "test string \x1b[31mwith\x1b[39m one \x1b[31mcolor\x1b[39m placeholders"
    )
Пример #2
0
def test_colorize_candy_color(strip_color):
    text = colorize("<c1>text</c1>", 1, ["candy"])
    assert strip_color(text) == "text"
    assert len(text) > len("text")
Пример #3
0
def test_colorize_without_color_placeholder():
    text = "test string without color placeholders"
    assert colorize(text, 1, []) == text
    assert colorize(text, 1, ["red"]) == "\x1b[31m{}\x1b[39m".format(text)