mirror of
https://github.com/thib8956/nginx-proxy
synced 2025-02-24 01:38:15 +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")
|
||||
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.
|
||||
|
||||
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
|
||||
our container will be attached to all the docker networks.
|
||||
"""
|
||||
original_dns_resolver = monkey_patch_urllib_dns_resolver()
|
||||
remove_all_containers()
|
||||
docker_compose_up(docker_compose_file)
|
||||
networks = connect_to_all_networks()
|
||||
@ -448,7 +454,6 @@ def docker_compose(docker_compose_file):
|
||||
for network in networks:
|
||||
disconnect_from_network(network)
|
||||
docker_compose_down(docker_compose_file)
|
||||
restore_urllib_dns_resolver(original_dns_resolver)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
|
Loading…
x
Reference in New Issue
Block a user