diff --git a/src/rendercv/cli/render_command/progress_panel.py b/src/rendercv/cli/render_command/progress_panel.py index 9f1f1b62..2756fa87 100644 --- a/src/rendercv/cli/render_command/progress_panel.py +++ b/src/rendercv/cli/render_command/progress_panel.py @@ -1,8 +1,8 @@ -import contextlib import pathlib from dataclasses import dataclass import rich.box +import rich.console import rich.live import rich.panel import rich.table @@ -27,7 +27,6 @@ class ProgressPanel(rich.live.Live): """ def __init__(self, quiet: bool = False): - self.quiet = quiet self.completed_steps: list[CompletedStep] = [] super().__init__( rich.panel.Panel( @@ -36,6 +35,7 @@ class ProgressPanel(rich.live.Live): title_align="left", border_style="bright_black", ), + console=rich.console.Console(quiet=quiet), refresh_per_second=4, ) @@ -63,18 +63,17 @@ class ProgressPanel(rich.live.Live): Args: title: Panel title text. """ - if self.quiet: - return - lines: list[str] = [] for step in self.completed_steps: paths_str = "" if step.paths: - with contextlib.suppress(ValueError): - step.paths = [ + try: + paths = [ path.relative_to(pathlib.Path.cwd()) for path in step.paths ] - paths_as_strings = [f"./{path}" for path in step.paths] + except ValueError: + paths = step.paths + paths_as_strings = [f"./{path}" for path in paths] paths_str = "; ".join(paths_as_strings) timing = f"[bold green]{step.timing_ms + ' ms':<8}[/bold green]" diff --git a/tests/cli/render_command/test_progress_panel.py b/tests/cli/render_command/test_progress_panel.py index 2cb5fd02..8454cd5a 100644 --- a/tests/cli/render_command/test_progress_panel.py +++ b/tests/cli/render_command/test_progress_panel.py @@ -51,16 +51,20 @@ class TestProgressPanelFinishProgress: class TestProgressPanelPrintProgressPanel: + def test_quiet_mode_produces_no_output(self, capsys): + with ProgressPanel(quiet=True) as panel: + panel.update_progress("100", "Test", []) + panel.finish_progress() + + captured = capsys.readouterr() + assert captured.out == "" + def test_respects_quiet_mode(self): panel = ProgressPanel(quiet=True) panel.completed_steps.append(CompletedStep("100", "Test", [])) panel.print_progress_panel("Test Title") - # In quiet mode, nothing should be printed/updated - # We can't easily test the internal state of rich.live.Live, so we just - # verify the method doesn't raise an error - def test_displays_step_without_paths(self): panel = ProgressPanel(quiet=True) panel.completed_steps.append(CompletedStep("100", "Validated input", []))