use fixture in oci_container_test.py to clean-up images after tests

This commit is contained in:
mayeut
2023-09-18 21:28:33 +02:00
parent 6d0890e7e0
commit ba11212a13
2 changed files with 29 additions and 15 deletions
+2 -6
View File
@@ -34,6 +34,8 @@ def build_frontend_env(request) -> dict[str, str]:
@pytest.fixture()
def docker_cleanup() -> Generator[None, None, None]:
def get_images() -> set[str]:
if detect_ci_provider() is None or platform != "linux":
return set()
images = subprocess.run(
["docker", "image", "ls", "--format", "{{json .ID}}"],
text=True,
@@ -42,12 +44,6 @@ def docker_cleanup() -> Generator[None, None, None]:
).stdout
return {json.loads(image.strip()) for image in images.splitlines() if image.strip()}
if detect_ci_provider() is None or platform != "linux":
try:
yield
finally:
pass
return
images_before = get_images()
try:
yield