Skip to main content

Test Docker container images

Project description

https://img.shields.io/pypi/v/seaworthy.svg https://readthedocs.org/projects/seaworthy/badge/?version=latest https://travis-ci.org/praekeltfoundation/seaworthy.svg?branch=develop https://codecov.io/gh/praekeltfoundation/seaworthy/branch/develop/graph/badge.svg

Seaworthy is a test harness for Docker container images. It allows you to use Docker containers and other Docker resources as fixtures for tests written in Python.

Seaworthy supports Python 3.4 and newer. You can find more information in the documentation.

A demo repository is available with a set of Seaworthy tests for a simple Django application. Seaworthy is also introduced in our blog post on continuous integration with Docker on Travis CI.

For more background on the design and purpose of Seaworthy, see our PyConZA 2018 talk (slides).

Quick demo

First install Seaworthy along with pytest using pip:

pip install seaworthy[pytest]

Write some tests in a file, for example, test_echo_container.py:

from seaworthy.definitions import ContainerDefinition

container = ContainerDefinition(
    'echo', 'jmalloc/echo-server',
    wait_patterns=[r'Echo server listening on port 8080'],
    create_kwargs={'ports': {'8080': None}})
fixture = container.pytest_fixture('echo_container')


def test_echo(echo_container):
    r = echo_container.http_client().get('/foo')
    assert r.status_code == 200
    assert 'HTTP/1.1 GET /foo' in r.text

Run pytest:

pytest -v test_echo_container.py

Project status

Seaworthy should be considered alpha-level software. It is well-tested and works well for the first few things we have used it for, but we would like to use it for more of our Docker projects, which may require some parts of Seaworthy to evolve further. See the project issues for known issues/shortcomings.

The project was originally split out of the tests we wrote for our docker-django-bootstrap project. There are examples of Seaworthy in use there.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for seaworthy, version 0.4.2
Filename, size & hash File type Python version Upload date
seaworthy-0.4.2-py3-none-any.whl (58.7 kB) View hashes Wheel py3
seaworthy-0.4.2.tar.gz (46.5 kB) View hashes Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page