From fdde850fc2b6d74b99da995cfed3b8524c093a8d Mon Sep 17 00:00:00 2001 From: Thomas LEVEIL Date: Sat, 11 Feb 2017 02:23:07 +0100 Subject: [PATCH] TESTS: pytest checks the existance of the jwilder/nginx-proxy:test image --- test2/README.md | 2 -- test2/conftest.py | 13 +++++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/test2/README.md b/test2/README.md index af77120..3e98976 100644 --- a/test2/README.md +++ b/test2/README.md @@ -60,8 +60,6 @@ So all the following domain names will resolve to the nginx-proxy container in t When using the `docker_compose` fixture in a test, pytest will try to find a yml file named after your test module filename. For instance, if your test module is `test_example.py`, then the `docker_compose` fixture will try to load a `test_example.yml` [docker compose file](https://docs.docker.com/compose/compose-file/). -The only requirement within that compose file is to have a container declared from the docker image `jwilder/nginx-proxy:test`. - Once the docker compose file found, the fixture will remove all containers, run `docker-compose up`, and finally your test will be executed. The fixture will run the _docker-compose_ command with the `-f` option to load the given compose file. So you can test your docker compose file syntax by running it yourself with: diff --git a/test2/conftest.py b/test2/conftest.py index 9ac36b2..2de6702 100644 --- a/test2/conftest.py +++ b/test2/conftest.py @@ -290,8 +290,6 @@ def docker_compose(request): """ docker_compose_file = find_docker_compose_file(request) original_dns_resolver = monkey_patch_urllib_dns_resolver() - if not check_sut_image(): - pytest.exit("The docker image 'jwilder/nginx-proxy:test' is missing") remove_all_containers() docker_compose_up(docker_compose_file) networks = connect_to_all_networks() @@ -330,3 +328,14 @@ def pytest_runtest_logreport(report): report.longrepr.addsection('nginx-proxy logs', docker_client.logs(container['Id'])) report.longrepr.addsection('nginx-proxy conf', get_nginx_conf_from_container(container['Id'])) + + +############################################################################### +# +# Check requirements +# +############################################################################### + + +if not check_sut_image(): + pytest.exit("The docker image 'jwilder/nginx-proxy:test' is missing") \ No newline at end of file