mirror of
https://github.com/containers/podman-compose.git
synced 2024-11-30 03:43:28 +01:00
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
|