Rende robusta decodifica output robocopy
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user