mirror of
https://github.com/thib8956/nginx-proxy
synced 2025-02-24 09:48:14 +00:00
tests: Factor out DNS monkey patching to its own fixture
This commit is contained in:
parent
09a2f40633
commit
f5a3492926
@ -429,7 +429,14 @@ def ca_root_certificate():
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="module")
|
@pytest.fixture(scope="module")
|
||||||
def docker_compose(docker_compose_file):
|
def monkey_patched_dns():
|
||||||
|
original_dns_resolver = monkey_patch_urllib_dns_resolver()
|
||||||
|
yield
|
||||||
|
restore_urllib_dns_resolver(original_dns_resolver)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="module")
|
||||||
|
def docker_compose(monkey_patched_dns, docker_compose_file):
|
||||||
"""Ensures containers described in a docker compose file are started.
|
"""Ensures containers described in a docker compose file are started.
|
||||||
|
|
||||||
A custom docker compose file name can be specified by overriding the `docker_compose_file`
|
A custom docker compose file name can be specified by overriding the `docker_compose_file`
|
||||||
@ -438,7 +445,6 @@ def docker_compose(docker_compose_file):
|
|||||||
Also, in the case where pytest is running from a docker container, this fixture makes sure
|
Also, in the case where pytest is running from a docker container, this fixture makes sure
|
||||||
our container will be attached to all the docker networks.
|
our container will be attached to all the docker networks.
|
||||||
"""
|
"""
|
||||||
original_dns_resolver = monkey_patch_urllib_dns_resolver()
|
|
||||||
remove_all_containers()
|
remove_all_containers()
|
||||||
docker_compose_up(docker_compose_file)
|
docker_compose_up(docker_compose_file)
|
||||||
networks = connect_to_all_networks()
|
networks = connect_to_all_networks()
|
||||||
@ -448,7 +454,6 @@ def docker_compose(docker_compose_file):
|
|||||||
for network in networks:
|
for network in networks:
|
||||||
disconnect_from_network(network)
|
disconnect_from_network(network)
|
||||||
docker_compose_down(docker_compose_file)
|
docker_compose_down(docker_compose_file)
|
||||||
restore_urllib_dns_resolver(original_dns_resolver)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user