Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
| 1 |
import pytest |
| 2 |
|
| 3 |
import progressbar |
| 4 |
|
| 5 |
|
| 6 |
@pytest.fixture(autouse=True) |
| 7 |
def large_interval(monkeypatch) -> None: |
| 8 |
# Remove the update limit for tests by default |
| 9 |
monkeypatch.setattr( |
| 10 |
progressbar.ProgressBar, |
| 11 |
'_MINIMUM_UPDATE_INTERVAL', |
| 12 |
0.1, |
| 13 |
) |
| 14 |
|
| 15 |
|
| 16 |
def test_end() -> None: |
| 17 |
m = 24514315 |
| 18 |
p = progressbar.ProgressBar( |
| 19 |
widgets=[progressbar.Percentage(), progressbar.Bar()], |
| 20 |
max_value=m, |
| 21 |
) |
| 22 |
|
| 23 |
for x in range(0, m, 8192): |
| 24 |
p.update(x) |
| 25 |
|
| 26 |
data = p.data() |
| 27 |
assert data['percentage'] < 100.0 |
| 28 |
|
| 29 |
p.finish() |
| 30 |
|
| 31 |
data = p.data() |
| 32 |
assert data['percentage'] >= 100.0 |
| 33 |
|
| 34 |
assert p.value == m |
| 35 |
|
| 36 |
|
| 37 |
def test_end_100(monkeypatch) -> None: |
| 38 |
assert progressbar.ProgressBar._MINIMUM_UPDATE_INTERVAL == 0.1 |
| 39 |
p = progressbar.ProgressBar( |
| 40 |
widgets=[progressbar.Percentage(), progressbar.Bar()], |
| 41 |
max_value=103, |
| 42 |
) |
| 43 |
|
| 44 |
for x in range(102): |
| 45 |
p.update(x) |
| 46 |
|
| 47 |
data = p.data() |
| 48 |
import pprint |
| 49 |
|
| 50 |
pprint.pprint(data) |
| 51 |
assert data['percentage'] < 100.0 |
| 52 |
|
| 53 |
p.finish() |
| 54 |
|
| 55 |
data = p.data() |
| 56 |
assert data['percentage'] >= 100.0 |