From f5f67a9ebb494dd65ad3eeb3437567e9da44d559 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Sat, 6 Nov 2021 12:27:32 +0000 Subject: [PATCH] fix for missing newline --- CHANGELOG.md | 1 + rich/live.py | 2 ++ tests/test_live.py | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e001201..933a703d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed an edge case bug when console module try to detect if they are in a tty at the end of a pytest run - Fixed issue with TERM env vars that have more than one hyphen https://github.com/willmcgugan/rich/issues/1640 +- Fixed missing new line after progress bar when terminal is not interactive https://github.com/willmcgugan/rich/issues/1606 ## [10.12.0] - 2021-10-06 diff --git a/rich/live.py b/rich/live.py index 8097f7d2..cb36ddb8 100644 --- a/rich/live.py +++ b/rich/live.py @@ -159,6 +159,8 @@ class Live(JupyterMixin, RenderHook): # jupyter last refresh must occur after console pop render hook # i am not sure why this is needed self.refresh() + if not self.console.is_interactive: + return self.console.print() def __enter__(self) -> "Live": self.start(refresh=self._renderable is not None) diff --git a/tests/test_live.py b/tests/test_live.py index 0c732f63..80002e54 100644 --- a/tests/test_live.py +++ b/tests/test_live.py @@ -158,7 +158,7 @@ def test_growing_display_file_console() -> None: output = console.end_capture() assert ( output - == "Step 0\nStep 1\nStep 2\nStep 3\nStep 4\nStep 5\nStep 6\nStep 7\nStep 8\nStep 9\n" + == "Step 0\nStep 1\nStep 2\nStep 3\nStep 4\nStep 5\nStep 6\nStep 7\nStep 8\nStep 9\n\n" )