Giter Site home page Giter Site logo

mfranzon / testcontainers-python Goto Github PK

View Code? Open in Web Editor NEW

This project forked from testcontainers/testcontainers-python

0.0 0.0 0.0 1.27 MB

Testcontainers is a Python library that providing a friendly API to run Docker container. It is designed to create runtime environment to use during your automatic tests.

Home Page: https://testcontainers-python.readthedocs.io/en/latest/

License: Apache License 2.0

Shell 0.03% Python 98.57% Makefile 0.92% Dockerfile 0.47%

testcontainers-python's Introduction

Ruff image image image codecov

Testcontainers Python

testcontainers-python facilitates the use of Docker containers for functional and integration testing.

For more information, see the docs.

Getting Started

>>> from testcontainers.postgres import PostgresContainer
>>> import sqlalchemy

>>> with PostgresContainer("postgres:16") as postgres:
...     engine = sqlalchemy.create_engine(postgres.get_connection_url())
...     with engine.begin() as connection:
...         result = connection.execute(sqlalchemy.text("select version()"))
...         version, = result.fetchone()
>>> version
'PostgreSQL 16...'

The snippet above will spin up a postgres database in a container. The get_connection_url() convenience method returns a sqlalchemy compatible url we use to connect to the database and retrieve the database version.

Configuration

Env Variable Example Description
TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE /var/run/docker.sock Path to Docker's socket used by ryuk
TESTCONTAINERS_RYUK_PRIVILEGED false Run ryuk as a privileged container
TESTCONTAINERS_RYUK_DISABLED false Disable ryuk
RYUK_CONTAINER_IMAGE testcontainers/ryuk:0.7.0 Custom image for ryuk
RYUK_RECONNECTION_TIMEOUT 10s Reconnection timeout for Ryuk TCP socket before Ryuk reaps all dangling containers

testcontainers-python's People

Contributors

tillahoffmann avatar gospodinkot avatar sergeypirogov avatar alexanderankin avatar maltehedderich avatar timbmg avatar pffijt avatar annabaas avatar github-actions[bot] avatar yakimka avatar totallyzen avatar max-pfeiffer avatar tuvshuud avatar balint-backmaker avatar tranquility2 avatar santi avatar bearrito avatar duchadian avatar kiview avatar spicy-sauce avatar dstape avatar vindex10 avatar eddumelendez avatar t0ch1k avatar lippertto avatar skirino avatar romank0 avatar robsdedude avatar kieranlea avatar jmorales4 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.