Closed aksel closed 3 weeks ago
Apologies if my PR breaks any conventions or contribution guidelines. I was a bit confused by the docs, as they seemed to be targeted towards contributing features, which I don't think this is.
Let me know if I should close, resubmit, or change anything
Thanks! :smile:
My specific use case is this:
import pytest
from testcontainers.compose import DockerCompose
@pytest.fixture(scope="session")
async def aws() -> DockerCompose:
with DockerCompose(
".",
compose_file_name="docker-compose.yaml",
pull=True,
build=True,
services=["aws"],
# Wait for localstack to be healthy
wait=True,
) as compose:
yield compose
@pytest.fixture(scope="module")
async def db(aws) -> DockerCompose:
with DockerCompose(
".",
compose_file_name="docker-compose.yaml",
pull=True,
build=True,
# Only start the DB
services=["db"],
# Wait for the DB to be healthy
wait=True,
) as compose:
yield compose
Starting up aws
takes a while, maybe around 20 seconds, but it can be session scoped and only done once. Until now, both have been session scoped. But now I want to get a clean DB in between modules (or packages, more likely). Nicer isolation and all that. But I couldn't figure out a way to stop only db
, while keeping aws
running. At first glance, seemed like an oversight, so I thought I might as well submit a PR with the two-line change.
All modified and coverable lines are covered by tests :white_check_mark:
Please upload report for BASE (
main@27f2a6b
). Learn more about missing BASE report.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
The command would otherwise stop/down all services, not just the services the instance itself started.
Useful for e.g. one fixture per service, and you want different scopes for the services.