mirror of
https://github.com/datahub-project/datahub.git
synced 2025-09-03 14:23:03 +00:00
test(ingest): simplify docker cleanup commands (#2699)
This commit is contained in:
parent
26dcece8ec
commit
7e9a04479b
@ -125,7 +125,7 @@ base_dev_requirements = {
|
|||||||
"mypy>=0.901",
|
"mypy>=0.901",
|
||||||
"pytest>=6.2.2",
|
"pytest>=6.2.2",
|
||||||
"pytest-cov>=2.8.1",
|
"pytest-cov>=2.8.1",
|
||||||
"pytest-docker",
|
"pytest-docker>=0.10.3",
|
||||||
"tox",
|
"tox",
|
||||||
"deepdiff",
|
"deepdiff",
|
||||||
"requests-mock",
|
"requests-mock",
|
||||||
|
@ -31,18 +31,11 @@ def wait_for_port(
|
|||||||
def docker_compose_runner(docker_compose_project_name, docker_cleanup):
|
def docker_compose_runner(docker_compose_project_name, docker_cleanup):
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def run(compose_file_path: str, key: str) -> pytest_docker.plugin.Services:
|
def run(compose_file_path: str, key: str) -> pytest_docker.plugin.Services:
|
||||||
try:
|
with pytest_docker.plugin.get_docker_services(
|
||||||
docker_services = pytest_docker.plugin.get_docker_services(
|
str(compose_file_path),
|
||||||
str(compose_file_path),
|
f"{docker_compose_project_name}-{key}",
|
||||||
f"{docker_compose_project_name}-{key}",
|
docker_cleanup,
|
||||||
docker_cleanup,
|
) as docker_services:
|
||||||
)
|
yield docker_services
|
||||||
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")
|
|
||||||
|
|
||||||
return run
|
return run
|
||||||
|
Loading…
x
Reference in New Issue
Block a user