Skip to main content

Library provides lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container

Project description

testcontainers-python

Build Status PyPI Documentation Status

Python port for testcontainers-java that allows using docker containers for functional and/or integration testing.

Testcontainers-python provides capabilities to spin up a docker containers for test purposes would that be a database, Selenium web browser or any other cotainer.

Currently available features:

  • Selenium Grid containers
  • Selenium Standalone containers
  • MySql Db container
  • MariaDb container
  • PostgreSQL Db container
  • Generic docker containers

Quick start

Installation

The testcontainers module is available from PyPI at:

and can be installed using pip, depending on which containers you need:

pip install testcontainers[mysql]
pip install testcontainers[postgresql]
pip install testcontainers[selenium]
# or with multiple
pip install testcontainers[mysql,postgresql,selenium]

Basic usage

Database containers

Allows to spin up docker database images such as MySQL, PostgreSQL, MariaDB and Oracle XE.

MySQL example

    config = MySqlContainer('mysql:5.7.17')
    with config as mysql:
        e = sqlalchemy.create_engine(mysql.get_connection_url())
        result = e.execute("select version()")

It will spin up MySQL version 5.7. Then you can connect to database using get_connection_url() method which returns sqlalchemy compatible url in format dialect+driver://username:password@host:port/database.

Detailed documentation

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

testcontainers-2.5.tar.gz (8.8 kB view details)

Uploaded Source

File details

Details for the file testcontainers-2.5.tar.gz.

File metadata

  • Download URL: testcontainers-2.5.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.3

File hashes

Hashes for testcontainers-2.5.tar.gz
Algorithm Hash digest
SHA256 26e35b46c67cc8e1e60dae6cdfe63a4e59840e8f0b338cdf8e3cc284168cadb3
MD5 d757497f1bf56531959c6d7e836fdf60
BLAKE2b-256 f8372636e51aba7007eaba07f88198805f28cabb26c51d5245aaa0c457c1eae5

See more details on using hashes here.

Supported by

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