test(cli): ✅ add tests for prune command
add tests for prune command and some code optimization and formatting.
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user