Merge pull request #878 from p12tic/tests-decoded-output

tests: Print decoded subprocess output in case of failure
This commit is contained in:
Povilas Kanapickas 2024-03-08 15:15:24 +02:00 committed by GitHub
commit c84b4c33fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

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