System testing with pytest and docker-py: example code!
This repo contains the example code which accompanies the presentation System Testing with pytest and docker-py.
In this repo:
- test_screencast.py - Example tests, one that succceds, and one that fails.
- conftest.py - pytest plugin to run our example service
- service - An example HTTP service, to be run by the tests
pull_image demonstrates how to pull an
image and check if it has succeeded, but is not used by the tests.
test__error isn't run by default, but if the
skip is removed,
it will demonstrate docker logs being provided in the case of an error.
We have tested these examples successfully on:
These platforms are not supported (the examples rely on being able to access the IP of the running container from the host):
- Docker beta for Mac or Windows
At this time (July 2016) the docker beta does not support accessing containers by IP from the host.
- Build the example image:
pushd service docker build -t service . popd
- Install dependencies:
(some_virtual_env) pip install -r test_requirements.txt
- Run the tests:
(some_virtual_env) py.test test_screencast.py
To demonstrate log output on test failure, remove
- Thanks to @BlueMonday for the code that checks if a pull request as failed, and for help with this problem in general!
- Thanks also to the test tools team (@BlueMonday, @MeabhG, Jordan Taekema) at @Demonware.