Open n1ngu opened 1 year ago
I realize I am writing this as a workaround on a docker_setup
fixture shortcoming: the docker executor is not available as a fixture and you can't yield multiple compose subcommands interleaved with some python instructions, only a single docker compose subcommand.
Ideally I'd like to be able to write something like
@pytest.fixture(scope="session")
def docker_setup(docker_services):
execute = docker_services._docker_compose.execute
execute("up -d service-a service-b")
docker_services.wait_until_responsive(check=is_service_a_ready)
docker_services.wait_until_responsive(check=is_service_b_ready)
execute(dedent("""\
run --rm service-c my-shell << EOF
something
very
complicated
EOF
"""))
execute("up -d service-c service-d")
but the docker_service
fixture depends on the docker_setup
fixture already!
This seems like a common use case and fairly trivial to implement. Is anyone working on this / are the maintainers open to MRs that would simplify this?
Most projects need some kind of initialization. So far I am copy-pasting this kind of scripts all over the projects
This sort of works, but I wonder if it would be worth to have some kind of utility to address this kind of need in pytest-docker.
Also, using
docker_services._docker_compose.execute
feels odd.