mirror of
https://github.com/containers/podman-compose.git
synced 2025-08-14 15:58:42 +02:00
Move all tests to single directory "tests"
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
This commit is contained in:
38
tests/integration/test_utils.py
Normal file
38
tests/integration/test_utils.py
Normal file
@ -0,0 +1,38 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
|
||||
class RunSubprocessMixin:
|
||||
def is_debug_enabled(self):
|
||||
return "TESTS_DEBUG" in os.environ
|
||||
|
||||
def run_subprocess(self, args):
|
||||
begin = time.time()
|
||||
if self.is_debug_enabled():
|
||||
print("TEST_CALL", args)
|
||||
proc = subprocess.Popen(
|
||||
args,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
)
|
||||
out, err = proc.communicate()
|
||||
if self.is_debug_enabled():
|
||||
print("TEST_CALL completed", time.time() - begin)
|
||||
print("STDOUT:", out.decode('utf-8'))
|
||||
print("STDERR:", err.decode('utf-8'))
|
||||
return out, err, proc.returncode
|
||||
|
||||
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: {decoded_out}\nstderr: {decoded_err}\n",
|
||||
)
|
||||
return out, err
|
Reference in New Issue
Block a user