def _test_progress_bar(backend, len, increment):
out = StringIO()
fill_str = ('123456890' * (len//10))[:len]
pb = DialogUI(out).get_progressbar('label', fill_str, maxval=10, backend=backend)
pb.start()
# we can't increment 11 times
for x in range(11):
if not (increment and x == 0):
# do not increment on 0
pb.update(x if not increment else 1, increment=increment)
out.flush() # needed atm
pstr = out.getvalue()
ok_startswith(pstr.lstrip('\r'), 'label:')
assert_re_in(r'.*\b%d%%.*' % (10*x), pstr)
if backend == 'progressbar':
assert_in('ETA', pstr)
pb.finish()
ok_endswith(out.getvalue(), '\n')
评论列表
文章目录