Skip to main content

"Provide an easy way to perform integration testing with docker and python"

Project description



Testcompose - A clean and better way to test your Python containerized applications.

PyPI - Python Version PyPI - Implementation PyPI PyPI - Downloads Tests

Testcompose provides an easy way of using docker containers for functional and integration testing. It allows for combination of more than one containers and allows for interactions with these containers from your test code without having to write extra scripts for such interactions. I.e providing a docker compose kind of functionality with the extra benefit of being able to fully control the containers from test codes.

This is inspired by the testcontainers-python project and goes further to add a few additional functionalities to improve software integration testing while allowing the engineer to control every aspect of the test.

Install testcompose using pip:

$ pip install testcompose

testcompose requires Python 3.7+.

Using a config file. See the Quickstart for other options

  - name: db1
    image: "postgres:13"
    command: ""
      POSTGRES_USER: postgres
      POSTGRES_DB: postgres
      POSTGRES_PASSWORD: password
      - 5432
      - host: "data_volume"
        container: "/data"
        mode: "rw"
        source: "dockervolume" # possible values are `dockervolume` or `filesystem`
      log_line_regex: "database system is ready to accept connections"
      wait_timeout_ms: 30
      poll_interval_ms: 2

Verify it as follows:

from testcompose.parse_config import TestConfigParser
from testcompose.configs.service_config import Config
from testcompose.run_containers import RunContainers
from testcompose.models.config.config_services import ConfigServices, Service

my_test_service: ConfigServices = TestConfigParser.parse_config(
my_config: Config =  Config(test_services=my_test_service)

with RunContainers(
) as runner:
    # Interract with the running containers

    assert runner.running_containers

    # Use some special parameters of the running containers

    app_container = runner.running_containers["app_container_config_name"].config_environment_variables

    # Get the host port a certain exposed container port is mapped to
    mapped_port = app_container.generic_container.get_exposed_port("8000")

    # where `port` is the exposed port of the 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

testcompose-0.0.12.tar.gz (23.9 kB view hashes)

Uploaded source

Built Distributions

testcompose-0.0.12-py3.9.egg (60.4 kB view hashes)

Uploaded 0 0 12

testcompose-0.0.12-py3-none-any.whl (29.7 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page