Beispiel #1
0
def test_highlight_text():
    s1 = "hello world"
    s2 = "hello {}orld".format(internals.bold("w"))
    assert internals.highlight_text(s1, "w") == s2

    s3 = "hell{}orld".format(internals.bold("o w"))
    assert internals.highlight_text(s2, "o ") == s3
Beispiel #2
0
def test_highlight_text_escapes_ansi():
    # Testing issue #78
    text = click.style("Green text", fg="green")
    assert "3" in text  # because it's part of the ANSI code for green
    assert internals.highlight_text(text, "3") == text

    assert "m" in text  # because it's part of the ANSI code for green
    assert internals.highlight_text(text, "m") == text
Beispiel #3
0
def test_highlight_text_with_color():
    s1 = "hello world"
    s2 = "hello {}orld".format(internals.bold("w"))
    f = lambda s: click.style(s, fg="green")
    assert internals.highlight_text(f(s1), "w") == f(s2)