Rende robusta decodifica output robocopy

This commit is contained in:
2026-07-02 11:41:09 +02:00
parent c113e81c2a
commit 8d6a5c55c4
2 changed files with 31 additions and 3 deletions

View File

@@ -7,6 +7,7 @@ from bakrest.backup import (
_build_robocopy_command,
_build_rsync_command,
_robocopy_destination_dir,
_run_command,
_run_robocopy,
_split_existing_files,
)
@@ -146,7 +147,7 @@ def test_robocopy_marks_each_file_copied_after_all_destinations(
pending_counts_after_commands: list[int] = []
def fake_run(command, capture_output, text, check):
def fake_run(command, **kwargs):
pending_counts_after_commands.append(registry.pending_count())
return subprocess.CompletedProcess(command, 0, stdout="", stderr="")
@@ -172,3 +173,19 @@ class _NullLogger:
def exception(self, *args, **kwargs) -> None:
pass
def test_run_command_uses_lossy_utf8_decoding(monkeypatch) -> None:
calls = {}
def fake_run(*args, **kwargs):
calls.update(kwargs)
return subprocess.CompletedProcess(args[0], 0, stdout="", stderr="")
monkeypatch.setattr("bakrest.backup.subprocess.run", fake_run)
_run_command(["robocopy"])
assert calls["encoding"] == "utf-8"
assert calls["errors"] == "replace"
assert calls["text"] is True