Skip to content

Latest commit

 

History

History
32 lines (20 loc) · 1.01 KB

README.rst

File metadata and controls

32 lines (20 loc) · 1.01 KB

Testcontainers Core

testcontainers-core is the core functionality for spinning up Docker containers in test environments.

.. autoclass:: testcontainers.core.container.DockerContainer

.. autoclass:: testcontainers.core.image.DockerImage

.. autoclass:: testcontainers.core.generic.DbContainer


Examples

Using DockerContainer and DockerImage to create a container:

>>> from testcontainers.core.container import DockerContainer
>>> from testcontainers.core.waiting_utils import wait_for_logs
>>> from testcontainers.core.image import DockerImage

>>> with DockerImage(path="./core/tests/image_fixtures/sample/", tag="test-sample:latest") as image:
...     with DockerContainer(str(image)) as container:
...         delay = wait_for_logs(container, "Test Sample Image")

The DockerImage class is used to build the image from the specified path and tag. The DockerContainer class is then used to create a container from the image.