Python port of Testcontainers - a library that supports pytest tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
This repository contains:
-
Python Implementation (main directory)
src/testcontainers/- Python source codetests/- Python test suitepyproject.toml- Python package configuration- See PROJECT_STATUS.md for detailed implementation status
-
Java Reference Implementation (
java_origin/directory)- Original Java testcontainers source code used as reference for the Python port
- See java_origin/README.md for details
Install the package:
pip install testcontainers-pythonUse a container in your tests:
from testcontainers.postgres import PostgresContainer
import sqlalchemy
def test_with_postgres():
with PostgresContainer("postgres:16") as postgres:
engine = sqlalchemy.create_engine(postgres.get_connection_url())
# Your test code here- Python Implementation: See PROJECT_STATUS.md for features, modules, and examples
- Original Java Documentation: https://java.testcontainers.org
See LICENSE.
Copyright (c) 2015 - 2021 Richard North and other authors.
MS SQL Server module is (c) 2017 - 2021 G DATA Software AG and other authors.
Hashicorp Vault module is (c) 2017 - 2021 Capital One Services, LLC and other authors.
See contributors for all contributors.