Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(namedtuple("Spinner", "frames")("-\\|/"), default_spinner),
# not hasattr(spinner, "frames") and hasattr(spinner, "interval")
(namedtuple("Spinner", "interval")(42), default_spinner),
# Both attrs, not set
(Spinner("", 0), default_spinner),
# Both attrs, not frames
(Spinner("", 42), default_spinner),
# Both attrs, not interval
(Spinner("-\\|/", 0), default_spinner),
# Both attrs, are set
(Spinner("-\\|/", 42), Spinner("-\\|/", 42)),
],
)
def test_set_spinner(spinner, expected):
swirl = yaspin(spinner)
assert swirl.spinner == expected
def test_spinner_setter(frames, interval):
swirl = yaspin()
assert swirl._spinner == default_spinner
assert isinstance(swirl._frames, str)
assert swirl._interval == swirl._spinner.interval * 0.001
assert isinstance(repr(swirl), builtin_str)
new_spinner = Spinner(frames, interval)
swirl.spinner = new_spinner
assert swirl._spinner == swirl._set_spinner(new_spinner)
if isinstance(swirl._frames, basestring):
assert isinstance(swirl._frames, str)
if isinstance(swirl._frames, (list, tuple)):
assert isinstance(swirl._frames[0], str)
assert swirl._interval == swirl._spinner.interval * 0.001
assert isinstance(repr(swirl), builtin_str)
def _set_spinner(spinner):
if hasattr(spinner, "frames") and hasattr(spinner, "interval"):
if not spinner.frames or not spinner.interval:
sp = default_spinner
else:
sp = spinner
else:
sp = default_spinner
return sp
def _set_spinner(spinner):
if hasattr(spinner, "frames") and hasattr(spinner, "interval"):
if not spinner.frames or not spinner.interval:
sp = default_spinner
else:
sp = spinner
else:
sp = default_spinner
return sp