# Path: yaspin/api.py
# def yaspin(*args, **kwargs):
#     """Display spinner in stdout.
# 
#     Can be used as a context manager or as a function decorator.
# 
#     Arguments:
#         spinner (base_spinner.Spinner, optional): Spinner object to use.
#         text (str, optional): Text to show along with spinner.
#         color (str, optional): Spinner color.
#         on_color (str, optional): Color highlight for the spinner.
#         attrs (list, optional): Color attributes for the spinner.
#         reversal (bool, optional): Reverse spin direction.
#         side (str, optional): Place spinner to the right or left end
#             of the text string.
#         sigmap (dict, optional): Maps POSIX signals to their respective
#             handlers.
#         timer (bool, optional): Prints a timer showing the elapsed time.
# 
#     Returns:
#         core.Yaspin: instance of the Yaspin class.
# 
#     Raises:
#         ValueError: If unsupported ``color`` is specified.
#         ValueError: If unsupported ``on_color`` is specified.
#         ValueError: If unsupported color attribute in ``attrs``
#             is specified.
#         ValueError: If trying to register handler for SIGKILL signal.
#         ValueError: If unsupported ``side`` is specified.
# 
#     Available text colors:
#         red, green, yellow, blue, magenta, cyan, white.
# 
#     Available text highlights:
#         on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan,
#         on_white, on_grey.
# 
#     Available attributes:
#         bold, dark, underline, blink, reverse, concealed.
# 
#     Example::
# 
#         # Use as a context manager
#         with yaspin():
#             some_operations()
# 
#         # Context manager with text
#         with yaspin(text="Processing..."):
#             some_operations()
# 
#         # Context manager with custom sequence
#         with yaspin(Spinner('-\\|/', 150)):
#             some_operations()
# 
#         # As decorator
#         @yaspin(text="Loading...")
#         def foo():
#             time.sleep(5)
# 
#         foo()
# 
#     """
#     return Yaspin(*args, **kwargs)
# 
# Path: yaspin/constants.py
# COLOR_MAP = {
#     # name: type
#     "blink": "attrs",
#     "bold": "attrs",
#     "concealed": "attrs",
#     "dark": "attrs",
#     "reverse": "attrs",
#     "underline": "attrs",
#     "blue": "color",
#     "cyan": "color",
#     "green": "color",
#     "magenta": "color",
#     "red": "color",
#     "white": "color",
#     "yellow": "color",
#     "on_blue": "on_color",
#     "on_cyan": "on_color",
#     "on_green": "on_color",
#     "on_grey": "on_color",
#     "on_magenta": "on_color",
#     "on_red": "on_color",
#     "on_white": "on_color",
#     "on_yellow": "on_color",
# }
# 
# SPINNER_ATTRS = [
#     "aesthetic",
#     "arc",
#     "arrow",
#     "arrow2",
#     "arrow3",
#     "balloon",
#     "balloon2",
#     "betaWave",
#     "bluePulse",
#     "bounce",
#     "bouncingBall",
#     "bouncingBar",
#     "boxBounce",
#     "boxBounce2",
#     "christmas",
#     "circle",
#     "circleHalves",
#     "circleQuarters",
#     "clock",
#     "dots",
#     "dots10",
#     "dots11",
#     "dots12",
#     "dots2",
#     "dots3",
#     "dots4",
#     "dots5",
#     "dots6",
#     "dots7",
#     "dots8",
#     "dots8Bit",
#     "dots9",
#     "dqpb",
#     "earth",
#     "fingerDance",
#     "fistBump",
#     "flip",
#     "grenade",
#     "growHorizontal",
#     "growVertical",
#     "hamburger",
#     "hearts",
#     "layer",
#     "line",
#     "line2",
#     "material",
#     "mindblown",
#     "monkey",
#     "moon",
#     "noise",
#     "orangeBluePulse",
#     "orangePulse",
#     "pipe",
#     "point",
#     "pong",
#     "runner",
#     "shark",
#     "simpleDots",
#     "simpleDotsScrolling",
#     "smiley",
#     "soccerHeader",
#     "speaker",
#     "squareCorners",
#     "squish",
#     "star",
#     "star2",
#     "timeTravel",
#     "toggle",
#     "toggle10",
#     "toggle11",
#     "toggle12",
#     "toggle13",
#     "toggle2",
#     "toggle3",
#     "toggle4",
#     "toggle5",
#     "toggle6",
#     "toggle7",
#     "toggle8",
#     "toggle9",
#     "triangle",
#     "weather",
# ]
# 
# Path: yaspin/spinners.py
# SPINNERS_DATA = pkgutil.get_data(__name__, "data/spinners.json").decode("utf-8")
# def _hook(dct):


import pytest
from yaspin import yaspin
from yaspin.constants import COLOR_MAP, SPINNER_ATTRS
from yaspin.spinners import Spinners
def test_set_spinner_by_name(attr_name):
    sp = getattr(yaspin(), attr_name)
    assert sp.spinner == getattr(Spinners, attr_name)


# Values for ``color`` argument
def test_color(color_test_cases):
    color, expected = color_test_cases
    # ``None`` and ``""`` are skipped
    if not color:
        pytest.skip("{0} - unsupported case".format(repr(color)))

    sp = yaspin()

    if isinstance(expected, Exception):
        with pytest.raises(AttributeError):
            getattr(sp, color)
    else:
        getattr(sp, color)
        assert sp.color == expected
        assert sp._color_func.keywords["color"] == expected  # pylint: disable=no-member


# Values for ``on_color`` argument
def test_on_color(on_color_test_cases):
    on_color, expected = on_color_test_cases
    # ``None`` and ``""`` are skipped
    if not on_color:
        pytest.skip("{0} - unsupported case".format(repr(on_color)))


# Path: yaspin/api.py
# def yaspin(*args, **kwargs):
#     """Display spinner in stdout.
# 
#     Can be used as a context manager or as a function decorator.
# 
#     Arguments:
#         spinner (base_spinner.Spinner, optional): Spinner object to use.
#         text (str, optional): Text to show along with spinner.
#         color (str, optional): Spinner color.
#         on_color (str, optional): Color highlight for the spinner.
#         attrs (list, optional): Color attributes for the spinner.
#         reversal (bool, optional): Reverse spin direction.
#         side (str, optional): Place spinner to the right or left end
#             of the text string.
#         sigmap (dict, optional): Maps POSIX signals to their respective
#             handlers.
#         timer (bool, optional): Prints a timer showing the elapsed time.
# 
#     Returns:
#         core.Yaspin: instance of the Yaspin class.
# 
#     Raises:
#         ValueError: If unsupported ``color`` is specified.
#         ValueError: If unsupported ``on_color`` is specified.
#         ValueError: If unsupported color attribute in ``attrs``
#             is specified.
#         ValueError: If trying to register handler for SIGKILL signal.
#         ValueError: If unsupported ``side`` is specified.
# 
#     Available text colors:
#         red, green, yellow, blue, magenta, cyan, white.
# 
#     Available text highlights:
#         on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan,
#         on_white, on_grey.
# 
#     Available attributes:
#         bold, dark, underline, blink, reverse, concealed.
# 
#     Example::
# 
#         # Use as a context manager
#         with yaspin():
#             some_operations()
# 
#         # Context manager with text
#         with yaspin(text="Processing..."):
#             some_operations()
# 
#         # Context manager with custom sequence
#         with yaspin(Spinner('-\\|/', 150)):
#             some_operations()
# 
#         # As decorator
#         @yaspin(text="Loading...")
#         def foo():
#             time.sleep(5)
# 
#         foo()
# 
#     """
#     return Yaspin(*args, **kwargs)
# 
# Path: yaspin/constants.py
# COLOR_MAP = {
#     # name: type
#     "blink": "attrs",
#     "bold": "attrs",
#     "concealed": "attrs",
#     "dark": "attrs",
#     "reverse": "attrs",
#     "underline": "attrs",
#     "blue": "color",
#     "cyan": "color",
#     "green": "color",
#     "magenta": "color",
#     "red": "color",
#     "white": "color",
#     "yellow": "color",
#     "on_blue": "on_color",
#     "on_cyan": "on_color",
#     "on_green": "on_color",
#     "on_grey": "on_color",
#     "on_magenta": "on_color",
#     "on_red": "on_color",
#     "on_white": "on_color",
#     "on_yellow": "on_color",
# }
# 
# SPINNER_ATTRS = [
#     "aesthetic",
#     "arc",
#     "arrow",
#     "arrow2",
#     "arrow3",
#     "balloon",
#     "balloon2",
#     "betaWave",
#     "bluePulse",
#     "bounce",
#     "bouncingBall",
#     "bouncingBar",
#     "boxBounce",
#     "boxBounce2",
#     "christmas",
#     "circle",
#     "circleHalves",
#     "circleQuarters",
#     "clock",
#     "dots",
#     "dots10",
#     "dots11",
#     "dots12",
#     "dots2",
#     "dots3",
#     "dots4",
#     "dots5",
#     "dots6",
#     "dots7",
#     "dots8",
#     "dots8Bit",
#     "dots9",
#     "dqpb",
#     "earth",
#     "fingerDance",
#     "fistBump",
#     "flip",
#     "grenade",
#     "growHorizontal",
#     "growVertical",
#     "hamburger",
#     "hearts",
#     "layer",
#     "line",
#     "line2",
#     "material",
#     "mindblown",
#     "monkey",
#     "moon",
#     "noise",
#     "orangeBluePulse",
#     "orangePulse",
#     "pipe",
#     "point",
#     "pong",
#     "runner",
#     "shark",
#     "simpleDots",
#     "simpleDotsScrolling",
#     "smiley",
#     "soccerHeader",
#     "speaker",
#     "squareCorners",
#     "squish",
#     "star",
#     "star2",
#     "timeTravel",
#     "toggle",
#     "toggle10",
#     "toggle11",
#     "toggle12",
#     "toggle13",
#     "toggle2",
#     "toggle3",
#     "toggle4",
#     "toggle5",
#     "toggle6",
#     "toggle7",
#     "toggle8",
#     "toggle9",
#     "triangle",
#     "weather",
# ]
# 
# Path: yaspin/spinners.py
# SPINNERS_DATA = pkgutil.get_data(__name__, "data/spinners.json").decode("utf-8")
# def _hook(dct):


# Path: tests/test_attrs.py
import pytest
from yaspin import yaspin
from yaspin.constants import COLOR_MAP, SPINNER_ATTRS
from yaspin.spinners import Spinners

def test_set_spinner_by_name(attr_name):
    sp = getattr(yaspin(), attr_name)
    assert sp.spinner == getattr(Spinners, attr_name)


# Values for ``color`` argument
def test_color(color_test_cases):
    color, expected = color_test_cases
    # ``None`` and ``""`` are skipped
    if not color:
        pytest.skip("{0} - unsupported case".format(repr(color)))

    sp = yaspin()

    if isinstance(expected, Exception):
        with pytest.raises(AttributeError):
            getattr(sp, color)
    else:
        getattr(sp, color)
        assert sp.color == expected
        assert sp._color_func.keywords["color"] == expected  # pylint: disable=no-member


# Values for ``on_color`` argument
def test_on_color(on_color_test_cases):
    on_color, expected = on_color_test_cases
    # ``None`` and ``""`` are skipped
    if not on_color:
        pytest.skip("{0} - unsupported case".format(repr(on_color)))


    sp = yaspin()