forked from wolph/python-progressbar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_data_transfer_bar.py
More file actions
31 lines (24 loc) · 830 Bytes
/
Copy pathtest_data_transfer_bar.py
File metadata and controls
31 lines (24 loc) · 830 Bytes
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
import io
import progressbar
from progressbar import DataTransferBar
def test_known_length() -> None:
dtb = DataTransferBar().start(max_value=50)
for i in range(50):
dtb.update(i)
dtb.finish()
def test_unknown_length() -> None:
dtb = DataTransferBar().start(max_value=progressbar.UnknownLength)
for i in range(50):
dtb.update(i)
dtb.finish()
def test_file_transfer_speed_before_any_data() -> None:
# Regression: B6 - before any data was transferred the widget
# rendered '0.0 s/B' using the inverse format.
widget = progressbar.FileTransferSpeed()
bar = progressbar.ProgressBar(
max_value=10, widgets=[widget], fd=io.StringIO(), term_width=60
)
bar.start()
output = widget(bar, bar.data())
assert 's/' not in output
bar.finish(dirty=True)