def test_spinner_update(): time = 0.0 def get_time(): nonlocal time return time console = Console(width=20, force_terminal=True, get_time=get_time, _environ={}) console.begin_capture() spinner = Spinner("dots") console.print(spinner) rule = Rule("Bar") spinner.update(text=rule) time += 80 / 1000 console.print(spinner) result = console.end_capture() print(repr(result)) expected = "⠋\n⠙ \x1b[92m─\x1b[0m\n" assert result == expected
def test_spinner_update(): time = 0.0 def get_time(): nonlocal time return time console = Console(width=20, force_terminal=True, get_time=get_time, _environ={}) console.begin_capture() spinner = Spinner("dots") console.print(spinner) spinner.update(text="Bar", style="green", speed=2) time += 80 / 1000 console.print(spinner) spinner.update(text=Rule("Bar")) time += 80 / 1000 console.print(spinner) result = console.end_capture() print(repr(result)) expected = f"⠋\n\x1b[32m⠙\x1b[0m Bar\n\x1b[32m⠸\x1b[0m \x1b[92m────── \x1b[0mBar\x1b[92m ───────\x1b[0m\n" assert result == expected