summaryrefslogtreecommitdiff
path: root/test/apiv2/rest_api/__init__.py
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2021-03-11 14:24:57 -0700
committerJhon Honce <jhonce@redhat.com>2021-03-11 14:24:57 -0700
commit92a8d69a70ce38ab107828d35dead106a1cc0437 (patch)
treea8e62cb60618f18764658502e979c634f0f087c4 /test/apiv2/rest_api/__init__.py
parent81737b37738dfa21be3cf9775919458523511ae9 (diff)
downloadpodman-92a8d69a70ce38ab107828d35dead106a1cc0437.tar.gz
podman-92a8d69a70ce38ab107828d35dead106a1cc0437.tar.bz2
podman-92a8d69a70ce38ab107828d35dead106a1cc0437.zip
Delete all containers and pods between tests
New tearDown() deletes all pods and containers between tests Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'test/apiv2/rest_api/__init__.py')
-rw-r--r--test/apiv2/rest_api/__init__.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/test/apiv2/rest_api/__init__.py b/test/apiv2/rest_api/__init__.py
index b7b8a7649..0ad6b51b3 100644
--- a/test/apiv2/rest_api/__init__.py
+++ b/test/apiv2/rest_api/__init__.py
@@ -3,6 +3,7 @@ import json
import os
import shutil
import subprocess
+import sys
import tempfile
@@ -27,7 +28,9 @@ class Podman(object):
self.cmd.append("--root=" + os.path.join(self.anchor_directory, "crio"))
self.cmd.append("--runroot=" + os.path.join(self.anchor_directory, "crio-run"))
- os.environ["CONTAINERS_REGISTRIES_CONF"] = os.path.join(self.anchor_directory, "registry.conf")
+ os.environ["CONTAINERS_REGISTRIES_CONF"] = os.path.join(
+ self.anchor_directory, "registry.conf"
+ )
p = configparser.ConfigParser()
p.read_dict(
{
@@ -114,13 +117,20 @@ class Podman(object):
check = kwargs.get("check", False)
shell = kwargs.get("shell", False)
- return subprocess.run(
- cmd,
- shell=shell,
- check=check,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- )
+ try:
+ return subprocess.run(
+ cmd,
+ shell=shell,
+ check=check,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ )
+ except subprocess.CalledProcessError as e:
+ if e.stdout:
+ sys.stdout.write("\nRun Stdout:\n" + e.stdout.decode("utf-8"))
+ if e.stderr:
+ sys.stderr.write("\nRun Stderr:\n" + e.stderr.decode("utf-8"))
+ raise
def tear_down(self):
shutil.rmtree(self.anchor_directory, ignore_errors=True)