Skip to content

Commit

Permalink
Merge pull request #1125 from JoshKarpel/really-disable-pbar
Browse files Browse the repository at this point in the history
Disabled Progress should not start attached Live
  • Loading branch information
willmcgugan committed Mar 26, 2021
2 parents 472ed32 + 34c5620 commit b9e0014
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
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

0 comments on commit b9e0014

Please sign in to comment.