From 9e397a13db9bd1db477d87729a756d671b40a4cf Mon Sep 17 00:00:00 2001 From: JoshKarpel Date: Sun, 21 Mar 2021 10:19:10 -0500 Subject: [PATCH] disabled progress does not start live --- rich/progress.py | 3 ++- tests/test_progress.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/rich/progress.py b/rich/progress.py index 8a246ee5..4f96d111 100644 --- a/rich/progress.py +++ b/rich/progress.py @@ -634,7 +634,8 @@ class Progress(JupyterMixin): def start(self) -> None: """Start the progress display.""" - self.live.start(refresh=True) + if not self.disable: + self.live.start(refresh=True) def stop(self) -> None: """Stop the progress display.""" diff --git a/tests/test_progress.py b/tests/test_progress.py index cca4ad6f..3d40d2e3 100644 --- a/tests/test_progress.py +++ b/tests/test_progress.py @@ -434,6 +434,20 @@ def test_progress_max_refresh() -> None: ) +def test_live_is_started_if_progress_is_enabled() -> None: + progress = Progress(auto_refresh=False, disable=False) + + with progress: + assert progress.live._started + + +def test_live_is_not_started_if_progress_is_disabled() -> None: + progress = Progress(auto_refresh=False, disable=True) + + with progress: + assert not progress.live._started + + if __name__ == "__main__": _render = render_progress() print(_render)