Skip to content
Example code to accompany our presentation
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
service
.gitignore
.travis.yml
LICENSE
README.md
cmdr_and_dockerpy.png
cmdr_and_pytest.png
conftest.py
keep_python_weird.png
labels.py
test_requirements.txt
test_screencast.py

README.md

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.

Build Status

The example code demonstrates how to use 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

In conftest.py, pull_image demonstrates how to pull an image and check if it has succeeded, but is not used by the tests.

The test 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.

Supported platforms

We have tested these examples successfully on:

  • Linux

These platforms are not supported (the examples rely on being able to access the IP of the running container from the host):

  • docker-machine
  • Docker beta for Mac or Windows

At this time (July 2016) the docker beta does not support accessing containers by IP from the host.

Running tests

  1. Build the example image:
pushd service
docker build -t service .
popd
  1. Install dependencies:
(some_virtual_env) pip install -r test_requirements.txt
  1. Run the tests:
(some_virtual_env) py.test test_screencast.py

To demonstrate log output on test failure, remove pytest.mark.skip from test__error.

Thanks!

  • 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.

You can’t perform that action at this time.