test(cli): ✅ add tests for prune command

add tests for prune command and some code optimization and formatting.
This commit is contained in:
2026-09-25 17:59:27 +02:00
parent 48503cdd42
commit e50797bba6
4 changed files with 91 additions and 22 deletions
+11
View File
@@ -34,6 +34,17 @@ def tmp_setup_logging(tmp_log_file):
setup_logging(file_path=tmp_log_file)
@pytest.fixture(autouse=True)
def tmp_cli_logging(monkeypatch, tmp_path):
"""Keep the CLI callback from writing run logs into the project `output/logs`.
The callback builds `LOGGING_PATH / <timestamp>.log` on every command call,
so `runner.invoke()` would otherwise create a file in the working tree and
add two handlers to the root logger for each test.
"""
monkeypatch.setattr("logwatcher.cli.LOGGING_PATH", tmp_path / "logs")
@pytest.fixture(name="original_log_dir")
def original_log_dir_fixture() -> Path:
"""Return log directory containing real logs.