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
  • OracleDb container
  • PostgreSQL Db container
  • Microsoft SQL Server 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[oracle]
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-3.0.0.tar.gz (10.2 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: testcontainers-3.0.0.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.5.6

File hashes

Hashes for testcontainers-3.0.0.tar.gz
Algorithm Hash digest
SHA256 ead47008f05a9fe7884dacebe36fe81f073d53fea2c82b7b19f44703a9d770e1
MD5 d616618303cdcd8efbfe30114f744cda
BLAKE2b-256 6afbc3c92c78761740cb2a07b5ca7ce83a382fa310c3aabd65239f6ea4118fd8

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