test that Progress writes nothing when disabled

This commit is contained in:
JoshKarpel 2021-03-25 17:33:49 -05:00
parent 3e079ff52b
commit 34c56204e9
1 changed files with 24 additions and 0 deletions

View File

@ -448,6 +448,30 @@ def test_live_is_not_started_if_progress_is_disabled() -> None:
assert not progress.live._started
def test_no_output_if_progress_is_disabled() -> None:
console = Console(
file=io.StringIO(),
force_terminal=True,
width=60,
color_system="truecolor",
legacy_windows=False,
_environ={},
)
progress = Progress(
console=console,
disable=True,
)
test = ["foo", "bar", "baz"]
expected_values = iter(test)
with progress:
for value in progress.track(test, description="test"):
assert value == next(expected_values)
result = console.file.getvalue()
print(repr(result))
expected = ""
assert result == expected
if __name__ == "__main__":
_render = render_progress()
print(_render)