forked from wolph/python-progressbar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfailure.py
More file actions
94 lines (63 loc) · 2.01 KB
/
failure.py
File metadata and controls
94 lines (63 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import pytest
import progressbar
def test_missing_format_values():
with pytest.raises(KeyError):
p = progressbar.ProgressBar(
widgets=[progressbar.widgets.FormatLabel('%(x)s')],
)
p.update(5)
def test_max_smaller_than_min():
with pytest.raises(ValueError):
progressbar.ProgressBar(min_value=10, max_value=5)
def test_no_max_value():
'''Looping up to 5 without max_value? No problem'''
p = progressbar.ProgressBar()
p.start()
for i in range(5):
p.update(i)
def test_correct_max_value():
'''Looping up to 5 when max_value is 10? No problem'''
p = progressbar.ProgressBar(max_value=10)
for i in range(5):
p.update(i)
def test_minus_max_value():
'''negative max_value, shouldn't work'''
p = progressbar.ProgressBar(min_value=-2, max_value=-1)
with pytest.raises(ValueError):
p.update(-1)
def test_zero_max_value():
'''max_value of zero, it could happen'''
p = progressbar.ProgressBar(max_value=0)
p.update(0)
with pytest.raises(ValueError):
p.update(1)
def test_one_max_value():
'''max_value of one, another corner case'''
p = progressbar.ProgressBar(max_value=1)
p.update(0)
p.update(0)
p.update(1)
with pytest.raises(ValueError):
p.update(2)
def test_changing_max_value():
'''Changing max_value? No problem'''
p = progressbar.ProgressBar(max_value=10)(range(20), max_value=20)
for i in p:
pass
def test_backwards():
'''progressbar going backwards'''
p = progressbar.ProgressBar(max_value=1)
p.update(1)
p.update(0)
def test_incorrect_max_value():
'''Looping up to 10 when max_value is 5? This is madness!'''
p = progressbar.ProgressBar(max_value=5)
for i in range(5):
p.update(i)
with pytest.raises(ValueError):
for i in range(5, 10):
p.update(i)
def test_deprecated_maxval():
progressbar.ProgressBar(maxval=5)
def test_deprecated_poll():
progressbar.ProgressBar(poll=5)