forked from testcontainers/testcontainers-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
22 lines (17 loc) · 802 Bytes
/
conftest.py
File metadata and controls
22 lines (17 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import pytest
from typing import Callable
from testcontainers.core.container import DockerClient
@pytest.fixture
def check_for_image() -> Callable[[str, bool], None]:
"""Warp the check_for_image function in a fixture"""
def _check_for_image(image_short_id: str, cleaned: bool) -> None:
"""
Validates if the image is present or not.
:param image_short_id: The short id of the image
:param cleaned: True if the image should not be present, False otherwise
"""
client = DockerClient()
images = client.client.images.list()
found = any(image.short_id.endswith(image_short_id) for image in images)
assert found is not cleaned, f'Image {image_short_id} was {"found" if cleaned else "not found"}'
return _check_for_image