Exemplo n.º 1
0
def color_craziness():
    setups = [
        (
            "Bold underline reverse cyan color",
            lambda frame: colored(frame, 'cyan', attrs=['bold', 'underline', 'reverse'])  # noqa
        ),
        (
            "Dark blink concealed white color",
            lambda frame: colored(frame, 'white', attrs=['dark', 'blink', 'concealed'])  # noqa
        ),
        (
            "Underline red on grey color",
            lambda frame: colored(frame, 'red', 'on_grey', attrs=['underline'])
        ),
        (
            "Reversed green on red color",
            lambda frame: colored(frame, 'green', 'on_red', attrs=['reverse'])
        ),
    ]
    # Setup printing
    max_len = 58
    msg = "[Color Craziness 🙀 ]"

    with yaspin(Spinners.pong) as sp:

        for name, color_func in setups:
            spaces_qty = max_len - len(name) - len(msg)
            text = "{0}{1}{2}".format(name, " " * spaces_qty, msg)

            sp.color = color_func
            sp.text = text

            time.sleep(1.3)
Exemplo n.º 2
0
def test_mixing():
    test_items = [
        ("Underline red on grey color",
         lambda frame: colored(frame, 'red', 'on_grey', attrs=['underline'])),
        ("Reversed green on red color",
         lambda frame: colored(frame, 'green', 'on_red', attrs=['reverse'])),
    ]
    for text, color_func in test_items:
        with yaspin(Spinners.pong, text=text, color=color_func):
            time.sleep(2)
Exemplo n.º 3
0
def test_attributes():
    test_items = [
        ("Bold gray color",
         lambda frame: colored(frame, 'grey', attrs=['bold'])),
        ("Dark red color",
         lambda frame: colored(frame, 'red', attrs=['dark'])),
        ("Underline green color",
         lambda frame: colored(frame, 'green', attrs=['underline'])),
        ("Blink yellow color",
         lambda frame: colored(frame, 'yellow', attrs=['blink'])),
        ("Reversed blue color",
         lambda frame: colored(frame, 'blue', attrs=['reverse'])),
        ("Concealed magenta color",
         lambda frame: colored(frame, 'magenta', attrs=['concealed'])),
        (
            "Bold underline reverse cyan color",
            lambda frame: colored(
                frame, 'cyan', attrs=['bold', 'underline', 'reverse'])  # noqa
        ),
        (
            "Dark blink concealed white color",
            lambda frame: colored(
                frame, 'white', attrs=['dark', 'blink', 'concealed'])  # noqa
        ),
    ]
    for text, color_func in test_items:
        with yaspin(Spinners.bouncingBar, text=text, color=color_func):
            time.sleep(2)
Exemplo n.º 4
0
def color_highlights():
    setups = [
        (
            "On gray color",
            lambda frame: colored(frame, on_color='on_grey')
        ),
        (
            "On red color",
            lambda frame: colored(frame, on_color='on_red')
        ),
        (
            "On green color",
            lambda frame: colored(frame, on_color='on_green')
        ),
        (
            "On yellow color",
            lambda frame: colored(frame, on_color='on_yellow')
        ),
        (
            "On blue color",
            lambda frame: colored(frame, on_color='on_blue')
        ),
        (
            "On magenta color",
            lambda frame: colored(frame, on_color='on_magenta')
        ),
        (
            "On cyan color",
            lambda frame: colored(frame, on_color='on_cyan')
        ),
        (
            "On white color",
            lambda frame: colored(frame, on_color='on_white')
        ),
    ]
    # Setup printing
    max_len = 40
    msg = "[Color Highlights]"

    with yaspin(Spinners.bouncingBall) as sp:

        for name, color_func in setups:
            spaces_qty = max_len - len(name) - len(msg)
            text = "{0}{1}{2}".format(name, " " * spaces_qty, msg)

            sp.color = color_func
            sp.text = text

            time.sleep(0.5)
Exemplo n.º 5
0
def test_highlights():
    test_items = [
        ("On gray color", lambda frame: colored(frame, on_color='on_grey')),
        ("On red color", lambda frame: colored(frame, on_color='on_red')),
        ("On green color", lambda frame: colored(frame, on_color='on_green')),
        ("On yellow color",
         lambda frame: colored(frame, on_color='on_yellow')),
        ("On blue color", lambda frame: colored(frame, on_color='on_blue')),
        ("On magenta color",
         lambda frame: colored(frame, on_color='on_magenta')),
        ("On cyan color", lambda frame: colored(frame, on_color='on_cyan')),
        ("On white color", lambda frame: colored(frame, on_color='on_white')),
    ]
    for text, color_func in test_items:
        with yaspin(Spinners.bouncingBall, text=text, color=color_func):
            time.sleep(2)
Exemplo n.º 6
0
def color_attributes():
    setups = [
        (
            "Bold gray color",
            lambda frame: colored(frame, 'grey', attrs=['bold'])
        ),
        (
            "Dark red color",
            lambda frame: colored(frame, 'red', attrs=['dark'])
        ),
        (
            "Underline green color",
            lambda frame: colored(frame, 'green', attrs=['underline'])
        ),
        (
            "Blink yellow color",
            lambda frame: colored(frame, 'yellow', attrs=['blink'])
        ),
        (
            "Reversed blue color",
            lambda frame: colored(frame, 'blue', attrs=['reverse'])
        ),
        (
            "Concealed magenta color",
            lambda frame: colored(frame, 'magenta', attrs=['concealed'])
        ),
    ]
    # Setup printing
    max_len = 42
    msg = "[Color Attributes]"

    with yaspin(Spinners.bouncingBall) as sp:

        for name, color_func in setups:
            spaces_qty = max_len - len(name) - len(msg)
            text = "{0}{1}{2}".format(name, " " * spaces_qty, msg)

            sp.color = color_func
            sp.text = text

            time.sleep(0.8)
Exemplo n.º 7
0
        ("cyan", "cyan"),
        ("white", "white"),

        # Unsupported text colors
        ("black", ValueError()),
        ("brown", ValueError()),
        ("orange", ValueError()),

        # Uppercase handling
        ("Red", "red"),
        ("grEEn", "green"),
        ("BlacK", ValueError()),

        # Callables
        (
            lambda frame: colored(frame, 'red', attrs=['bold']),
            lambda frame: colored(frame, 'red', attrs=['bold']),
        ),
    ])
def colors_test_cases(request):
    return request.param


@pytest.fixture(scope="session",
                ids=color_id_func,
                params=[
                    "red",
                    "green",
                    "yellow",
                    "blue",
                    "magenta",