Skip to content
Open
Changes from 2 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
10 changes: 7 additions & 3 deletions src/pytest_docker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,22 +140,26 @@ def docker_compose_project_name():

@pytest.fixture(scope='session')
def docker_services(
docker_compose_file, docker_compose_project_name
request, docker_compose_file, docker_compose_project_name
):
"""Ensure all Docker-based services are up and running."""

def _cleanup():
docker_compose.execute('down -v')

docker_compose = DockerComposeExecutor(
docker_compose_file, docker_compose_project_name
)

# If failure happens beyond this point, run cleanup
Comment thread
josh-drapeau marked this conversation as resolved.
request.addfinalizer(_cleanup)

# Spawn containers.
docker_compose.execute('up --build -d')

# Let test(s) run.
yield Services(docker_compose)
Comment thread
josh-drapeau marked this conversation as resolved.
Outdated

# Clean up.
docker_compose.execute('down -v')


__all__ = (
Expand Down