FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-progressbar/tests/test_timer.py at develop · SourceryAI/python-progressbar · GitHub
SourceryAI
/
python-progressbar
Public
forked from
wolph/python-progressbar
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-progressbar
/
tests
/
test_timer.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
48 lines (38 loc) · 1.34 KB
Breadcrumbs
python-progressbar
/
tests
/
test_timer.py
Copy path
File metadata and controls
48 lines (38 loc) · 1.34 KB
Raw
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
import
pytest
from
datetime
import
timedelta
import
progressbar
@
pytest
.
mark
.
parametrize
(
'poll_interval,expected'
, [
(
1
,
1
),
(
timedelta
(
seconds
=
1
),
1
),
(
0.001
,
0.001
),
(
timedelta
(
microseconds
=
1000
),
0.001
),
])
@
pytest
.
mark
.
parametrize
(
'parameter'
, [
'poll_interval'
,
'min_poll_interval'
,
])
def
test_poll_interval
(
parameter
,
poll_interval
,
expected
):
# Test int, float and timedelta intervals
bar
=
progressbar
.
ProgressBar
(
**
{
parameter
:
poll_interval
})
assert
getattr
(
bar
,
parameter
)
==
expected
@
pytest
.
mark
.
parametrize
(
'interval'
, [
1
,
timedelta
(
seconds
=
1
),
])
def
test_intervals
(
monkeypatch
,
interval
):
monkeypatch
.
setattr
(
progressbar
.
ProgressBar
,
'_MINIMUM_UPDATE_INTERVAL'
,
interval
)
bar
=
progressbar
.
ProgressBar
(
max_value
=
100
)
# Initially there should be no last_update_time
assert
bar
.
last_update_time
is
None
# After updating there should be a last_update_time
bar
.
update
(
1
)
assert
bar
.
last_update_time
# We should not need an update if the time is nearly the same as before
last_update_time
=
bar
.
last_update_time
bar
.
update
(
2
)
assert
bar
.
last_update_time
==
last_update_time
# We should need an update if we're beyond the poll_interval
bar
.
_last_update_time
-=
2
bar
.
update
(
3
)
assert
bar
.
last_update_time
!=
last_update_time
Back
|
FazBrowse Home
|
New Git URL