mirror of
https://github.com/Textualize/rich.git
synced 2026-02-06 19:08:05 +00:00
Merge pull request #3905 from TomerYogev/extra-blank-line-on-disabled-progress
Update progress.py
This commit is contained in:
commit
fe55a131c2
@ -5,12 +5,12 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## Unreleased
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Fixed
|
||||
|
||||
- IPython now respects when a `Console` instance is passed to `pretty.install` https://github.com/Textualize/rich/pull/3915
|
||||
- Fixed extraneous blank line on non-interactive disabled `Progress` https://github.com/Textualize/rich/pull/3905
|
||||
|
||||
### Added
|
||||
|
||||
|
||||
@ -82,6 +82,7 @@ The following people have contributed to the development of Rich:
|
||||
- [Motahhar Mokfi](https://github.com/motahhar)
|
||||
- [Tomer Shalev](https://github.com/tomers)
|
||||
- [Serkan UYSAL](https://github.com/uysalserkan)
|
||||
- [Tomer Yogev](https://github.com/TomerYogev)
|
||||
- [Zhe Huang](https://github.com/onlyacat)
|
||||
- [Adrian Zuber](https://github.com/xadrianzetx)
|
||||
- [Ke Sun](https://github.com/ksun212)
|
||||
|
||||
@ -1172,9 +1172,10 @@ class Progress(JupyterMixin):
|
||||
|
||||
def stop(self) -> None:
|
||||
"""Stop the progress display."""
|
||||
self.live.stop()
|
||||
if not self.console.is_interactive and not self.console.is_jupyter:
|
||||
self.console.print()
|
||||
if not self.disable:
|
||||
self.live.stop()
|
||||
if not self.console.is_interactive and not self.console.is_jupyter:
|
||||
self.console.print()
|
||||
|
||||
def __enter__(self) -> Self:
|
||||
self.start()
|
||||
|
||||
@ -565,6 +565,30 @@ def test_no_output_if_progress_is_disabled() -> None:
|
||||
assert result == expected
|
||||
|
||||
|
||||
def test_no_output_if_progress_is_disabled_non_interactive() -> None:
|
||||
console = Console(
|
||||
file=io.StringIO(),
|
||||
force_interactive=False,
|
||||
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
|
||||
|
||||
|
||||
def test_open() -> None:
|
||||
console = Console(
|
||||
file=io.StringIO(),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user