tests: Print decoded subprocess output in case of failure

Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
This commit is contained in:
Povilas Kanapickas 2024-03-08 15:10:46 +02:00
parent a494f20e15
commit 0614687840

View File

@ -15,10 +15,12 @@ class RunSubprocessMixin:
def run_subprocess_assert_returncode(self, args, expected_returncode=0):
out, err, returncode = self.run_subprocess(args)
decoded_out = out.decode('utf-8')
decoded_err = err.decode('utf-8')
self.assertEqual(
returncode,
expected_returncode,
f"Invalid return code of process {returncode} != {expected_returncode}\n"
f"stdout: {out}\nstderr: {err}\n",
f"stdout: {decoded_out}\nstderr: {decoded_err}\n",
)
return out, err