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
  • 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-2.6.0.tar.gz (8.9 kB view details)

Uploaded Source

File details

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

File metadata

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

File hashes

Hashes for testcontainers-2.6.0.tar.gz
Algorithm Hash digest
SHA256 16f5cda7484b1f19bcd5de5dacea26f2aa99d79a744ed5f2f141c6c23eac4f4a
MD5 888ec6a392650cd5d3f07fed1f89b5d4
BLAKE2b-256 1035bdfaf4b35a38f91331cb42c6fa00454dd0938e95cee9e403a8512ed51516

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