Skip to main content

A set of tools for creating declarative docker py.test integration fixtures.

Project description

pytest-docker-tools

This package contains some opinionated helpers for Dockerized integration testing drive by py.test.

You can define your fixtures in your conftest.py or in the test module where you are using them.

A simple example of a container built from an image with a volume attached:

from pytest_docker_tools.factories import *

container(
    'my_microservice',
    image('my_microservice_image', path='.'),
    volumes={
      volume('my_microservice_data'): {'bind': '/var/tmp'},
    }
)

Wherever possible the arguments to container_fixture mirror the arguments to the python docker libraries run() API.

You can create containers that depend on other containers:

from pytest_docker_tools.factories import *

container(
    'my_database',
    image('my_database_image', path='db'),
    volumes={
      volume('my_microservice_data'): {'bind': '/var/tmp'},
    }
)

container(
    'my_microservice',
    image('my_microservice_image', path='microservice'),
    environment={
      'DATABASE_IP': lambda my_database: my_database['ip'],
    }
)

Whenever you create a test that uses the my_microservice container it will also start a database container.

Project details


Download files

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

Source Distribution

pytest_docker_tools-0.0.2.tar.gz (7.4 kB view hashes)

Uploaded Source

Built Distribution

pytest_docker_tools-0.0.2-py3-none-any.whl (18.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page