RabbitMqContainer (rabbitmq/__init__.py)

testcontainers-python · src/testcontainers/community/rabbitmq/__init__.py · python · Apache-2.0
infra

Provides a Docker-based RabbitMQ container for integration testing, allowing developers to easily manage broker lifecycles and connections.

# Source: https://github.com/testcontainers/testcontainers-python | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
import os
from typing import Optional

import pika
from typing_extensions import Self

from testcontainers.core.container import DockerContainer
from testcontainers.core.waiting_utils import wait_container_is_ready


class RabbitMqContainer(DockerContainer):
    """
    Test container for RabbitMQ. The example below spins up a RabbitMQ broker and uses the
    `pika client library <https://pypi.org/project/pika/>`__ to establish a connection to the
    broker.

    Example:

        .. doctest::

            >>> import pika
            >>> from testcontainers.community.r

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key