test(ingest): simplify docker cleanup commands (#2699)

This commit is contained in:
Harshal Sheth 2021-06-16 16:59:28 -07:00 committed by GitHub
parent 26dcece8ec
commit 7e9a04479b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 14 deletions

View File

@ -125,7 +125,7 @@ base_dev_requirements = {
"mypy>=0.901",
"pytest>=6.2.2",
"pytest-cov>=2.8.1",
"pytest-docker",
"pytest-docker>=0.10.3",
"tox",
"deepdiff",
"requests-mock",

View File

@ -31,18 +31,11 @@ def wait_for_port(
def docker_compose_runner(docker_compose_project_name, docker_cleanup):
@contextlib.contextmanager
def run(compose_file_path: str, key: str) -> pytest_docker.plugin.Services:
try:
docker_services = pytest_docker.plugin.get_docker_services(
str(compose_file_path),
f"{docker_compose_project_name}-{key}",
docker_cleanup,
)
yield docker_services.__enter__()
finally:
# This setup exists because the underlying pytest_docker library does not
# wrap it's cleanup routine in a `finally` block.
# See this PR: https://github.com/avast/pytest-docker/pull/58.
docker_services.__exit__(None, None, None)
print("called docker-compose cleanup")
with pytest_docker.plugin.get_docker_services(
str(compose_file_path),
f"{docker_compose_project_name}-{key}",
docker_cleanup,
) as docker_services:
yield docker_services
return run