Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/pytest_docker/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
import pytest


class PytestDockerError(Exception):
"""Base pytest-docker exception."""


class ServiceTimeoutError(PytestDockerError):
"""
Timed out while waiting for Docker service(s).
"""


def execute(command, success_codes=(0,)):
"""Run a shell command."""
try:
Expand Down Expand Up @@ -105,7 +115,7 @@ def wait_until_responsive(self, check, timeout, pause, clock=timeit.default_time
time.sleep(pause)
now = clock()

raise Exception("Timeout reached while waiting on service!")
raise ServiceTimeoutError("Timeout reached while waiting on service!")


def str_to_list(arg):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_docker_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pytest_docker.plugin import (
DockerComposeExecutor,
Services,
ServiceTimeoutError,
get_docker_services,
get_cleanup_command,
get_setup_command,
Expand Down Expand Up @@ -166,7 +167,7 @@ def test_wait_until_responsive_timeout():
compose_project_name="pytest123",
)
services = Services(docker_compose)
with pytest.raises(Exception) as exc:
with pytest.raises(ServiceTimeoutError) as exc:
print(
services.wait_until_responsive(
check=lambda: False, timeout=3.0, pause=1.0, clock=clock
Expand Down