Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion test/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ def test_encoding(host):
elif host.backend.get_connection_type() == "ansible" and host.backend.force_ansible:
# XXX: this encoding issue comes directly from ansible
# not sure how to handle this...
assert (
assert cmd.failed
assert "surrogates not allowed" in cmd.stderr or (
cmd.stderr
== "ls: impossible d'acc\udce9der \udce0 '/é': Aucun fichier ou dossier de ce type"
)
Expand Down
2 changes: 1 addition & 1 deletion test/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_package(host, docker_image):
assert not host.package("zsh").is_installed
ssh = host.package("openssh-server")
version = {
"rockylinux9": "8.",
"rockylinux9": "9.",
"debian_bookworm": "1:9.2",
}[docker_image]
assert ssh.is_installed
Expand Down
9 changes: 7 additions & 2 deletions testinfra/backend/ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,16 @@ def run(self, command: str, *args: str, **kwargs: Any) -> base.CommandResult:
data = json.loads(out["module_stdout"])
stdout = data["stdout"]
stderr = data["stderr"]
else:
elif "stdout" in out:
# bw compat
stdout = out["stdout"]
stderr = out["stderr"]
return self.result(out["rc"], self.encode(command), stdout, stderr)
else:
# Ansible command failed (e.g. encoding error) with only a msg
stdout = ""
stderr = out.get("msg", "")
rc = out.get("rc", 1)
return self.result(rc, self.encode(command), stdout, stderr)

def run_ansible(
self, module_name: str, module_args: Optional[str] = None, **kwargs: Any
Expand Down
Loading