Skip to content

Commit 6e24819

Browse files
Sander Cornelissensalty-vagrant
andauthored
Fix Salt decode error (#636)
* Fix #398 `salt` backend returning non-encoded strings `salt` backend failed because local satl client returns `stdout` and `stderr` as `str` objects not encoded `bytes`. Taking a lead from the `ansible` implementation the `stdout` and `stderr` results are both encoded and returned as `kwargs` through `base.result` method. Co-authored-by: Mark Bools <[email protected]>
1 parent 78bfa6c commit 6e24819

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

testinfra/backend/salt.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@ def client(self):
3636
def run(self, command, *args, **kwargs):
3737
command = self.get_command(command, *args)
3838
out = self.run_salt("cmd.run_all", [command])
39-
return self.result(out["retcode"], command, out["stdout"], out["stderr"])
39+
return self.result(
40+
out["retcode"],
41+
command,
42+
out["stdout"].encode("utf8"),
43+
out["stderr"].encode("utf8"),
44+
stdout=out["stdout"],
45+
stderr=out["stderr"],
46+
)
4047

4148
def run_salt(self, func, args=None):
4249
out = self.client.cmd(self.host, func, args or [])

0 commit comments

Comments
 (0)