Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabled Progress should not start attached Live #1125

Merged
merged 4 commits into from Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -35,7 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed table style taking precedence over row style https://github.com/willmcgugan/rich/issues/1129
- Fixed incorrect measurement of Text with new lines and whitespace https://github.com/willmcgugan/rich/issues/1133
- Made type annotations consistent for various `total` keyword arguments in `rich.progress` and rich.`progress_bar`

- Disabled Progress no longer displays itself when starting https://github.com/willmcgugan/rich/pull/1125

## [9.13.0] - 2021-03-06

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Expand Up @@ -6,6 +6,7 @@ The following people have contributed to the development of Rich:

- [Oleksis Fraga](https://github.com/oleksis)
- [Finn Hughes](https://github.com/finnhughes)
- [Josh Karpel](https://github.com/JoshKarpel)
- [Hedy Li](https://github.com/hedythedev)
- [Alexander Mancevice](https://github.com/amancevice)
- [Will McGugan](https://github.com/willmcgugan)
Expand Down
3 changes: 2 additions & 1 deletion rich/progress.py
Expand Up @@ -634,7 +634,8 @@ def finished(self) -> bool:

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."""
Expand Down
38 changes: 38 additions & 0 deletions tests/test_progress.py
Expand Up @@ -434,6 +434,44 @@ def get_time() -> float:
)


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


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)
Expand Down