Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
117 lines (82 loc) · 2.65 KB

File metadata and controls

117 lines (82 loc) · 2.65 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import time
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):
time.sleep(1)
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):
time.sleep(1)
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:
time.sleep(1)
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):
time.sleep(1)
p.update(i)
with pytest.raises(ValueError):
for i in range(5, 10):
time.sleep(1)
p.update(i)
def test_deprecated_maxval():
with pytest.warns(DeprecationWarning):
progressbar.ProgressBar(maxval=5)
def test_deprecated_poll():
with pytest.warns(DeprecationWarning):
progressbar.ProgressBar(poll=5)
def test_unexpected_update_keyword_arg():
p = progressbar.ProgressBar(max_value=10)
with pytest.raises(TypeError):
for i in range(10):
time.sleep(1)
p.update(i, foo=10)
def test_dynamic_message_not_str():
with pytest.raises(TypeError):
progressbar.DynamicMessage(1)
def test_dynamic_message_too_many_strs():
with pytest.raises(ValueError):
progressbar.DynamicMessage('too long')
Morty Proxy This is a proxified and sanitized view of the page, visit original site.