This commit is contained in:
@@ -54,15 +54,36 @@ def test_set_progress_multiple_points():
|
|||||||
|
|
||||||
for i, (expected_progress, expected_value) in enumerate([
|
for i, (expected_progress, expected_value) in enumerate([
|
||||||
("0%", "0/5"),
|
("0%", "0/5"),
|
||||||
("20%", "1/5"),
|
("20%", "1.0/5"),
|
||||||
("40%", "2/5"),
|
("40%", "2.0/5"),
|
||||||
("70%", "3.5/5.0"),
|
("70%", "3.5/5"),
|
||||||
("100%", "5/5"),
|
("100%", "5.0/5"),
|
||||||
]):
|
]):
|
||||||
assert re.search(r"^SetBar:\s+" + re.escape(expected_progress), lines[i])
|
assert re.search(r"^SetBar:\s+" + re.escape(expected_progress), lines[i])
|
||||||
assert expected_value in lines[i]
|
assert expected_value in lines[i]
|
||||||
bar = get_bar_visual(lines[i])
|
bar = get_bar_visual(lines[i])
|
||||||
|
|
||||||
|
# test format_sizeof rounding
|
||||||
|
def test_set_progress_decimal_precision():
|
||||||
|
f = io.StringIO()
|
||||||
|
with redirect_stdout(f):
|
||||||
|
bar = tqdm_mod(total=5, desc="FloatBar", file=f, miniters=1, mininterval=0)
|
||||||
|
bar.set(1.3333)
|
||||||
|
bar.set(3.6666)
|
||||||
|
bar.set(4.999)
|
||||||
|
bar.close()
|
||||||
|
|
||||||
|
lines = extract_lines(f.getvalue(), "FloatBar")
|
||||||
|
|
||||||
|
expected_values = [
|
||||||
|
"1.3/5",
|
||||||
|
"3.7/5",
|
||||||
|
"5.0/5",
|
||||||
|
]
|
||||||
|
|
||||||
|
for expected in expected_values:
|
||||||
|
assert any(expected in line for line in lines), f"{expected} not found in output:\n" + "\n".join(lines)
|
||||||
|
|
||||||
def test_custom_unit():
|
def test_custom_unit():
|
||||||
f = io.StringIO()
|
f = io.StringIO()
|
||||||
with redirect_stdout(f):
|
with redirect_stdout(f):
|
||||||
|
|||||||
Reference in New Issue
Block a user