def test_render(): bar = ProgressBar(completed=11, width=50) bar_render = render(bar) assert bar_render == expected[0] bar.update(completed=12) bar_render = render(bar) assert bar_render == expected[1]
def test_update(): bar = ProgressBar() assert bar.completed == 0 assert bar.total == 100 bar.update(10, 20) assert bar.completed == 10 assert bar.total == 20 assert bar.percentage_completed == 50 bar.update(100) assert bar.percentage_completed == 100
Segment("━", Style.parse("red"), False), Segment("━", Style.parse("red"), False), Segment("━", Style.parse("red"), False), Segment("━", Style.parse("red"), False), Segment("━", Style.parse("red"), False), Segment("━", Style.parse("red"), False), Segment("━", Style.parse("red"), False), Segment("━", Style.parse("red"), False), Segment("━", Style.parse("red"), False), Segment("━", Style.parse("yellow"), False), Segment("━", Style.parse("yellow"), False), Segment("━", Style.parse("yellow"), False), Segment("━", Style.parse("yellow"), False), Segment("━", Style.parse("yellow"), False), Segment("━", Style.parse("yellow"), False), Segment("━", Style.parse("yellow"), False), Segment("━", Style.parse("yellow"), False), Segment("━", Style.parse("yellow"), False), Segment("━", Style.parse("yellow"), False), ] assert segments == expected if __name__ == "__main__": bar = ProgressBar(completed=11, width=50) bar_render = render(bar) print(repr(bar_render)) bar.update(completed=12) bar_render = render(bar) print(repr(bar_render))