mirror of
https://github.com/containers/podman-compose.git
synced 2024-11-29 11:23:50 +01:00
f4dc5f3b93
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
25 lines
715 B
Python
25 lines
715 B
Python
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
import subprocess
|
|
|
|
|
|
class RunSubprocessMixin:
|
|
def run_subprocess(self, args):
|
|
proc = subprocess.Popen(
|
|
args,
|
|
stdout=subprocess.PIPE,
|
|
stderr=subprocess.PIPE,
|
|
)
|
|
out, err = proc.communicate()
|
|
return out, err, proc.returncode
|
|
|
|
def run_subprocess_assert_returncode(self, args, expected_returncode=0):
|
|
out, err, returncode = self.run_subprocess(args)
|
|
self.assertEqual(
|
|
returncode,
|
|
expected_returncode,
|
|
f"Invalid return code of process {returncode} != {expected_returncode}\n"
|
|
f"stdout: {out}\nstderr: {err}\n",
|
|
)
|
|
return out, err
|