import time import pytest import progressbar2 def test_list() -> None: """Progressbar can guess max_value automatically.""" p = progressbar2.ProgressBar() for _i in p(range(10)): time.sleep(0.001) def test_iterator_with_max_value() -> None: """Progressbar can't guess max_value.""" p = progressbar2.ProgressBar(max_value=10) for _i in p(iter(range(10))): time.sleep(0.001) def test_iterator_without_max_value_error() -> None: """Progressbar can't guess max_value.""" p = progressbar2.ProgressBar() for _i in p(iter(range(10))): time.sleep(0.001) assert p.max_value is progressbar2.UnknownLength def test_iterator_without_max_value() -> None: """Progressbar can't guess max_value.""" p = progressbar2.ProgressBar( widgets=[ progressbar2.AnimatedMarker(), progressbar2.FormatLabel('%(value)d'), progressbar2.BouncingBar(), progressbar2.BouncingBar(marker=progressbar2.RotatingMarker()), ], ) for _i in p(iter(range(10))): time.sleep(0.001) def test_iterator_with_incorrect_max_value() -> None: """Progressbar can't guess max_value.""" p = progressbar2.ProgressBar(max_value=10) with pytest.raises(ValueError): for _i in p(iter(range(20))): time.sleep(0.001) def test_adding_value() -> None: p = progressbar2.ProgressBar(max_value=10) p.start() p.update(5) p += 2 p.increment(2) with pytest.raises(ValueError): p += 5