Registry / testing / pytest-rabbitmq

pytest-rabbitmq

JSON →
library4.0.0pypypi✓ verified 82d ago

pytest-rabbitmq provides pytest fixtures for spinning up a RabbitMQ process and client connections. Version 4.0.0 requires Python >=3.10 and uses async fixtures by default. Release cadence is irregular, driven by maintenance needs.

pip install pytest-rabbitmq
INSTALL
IMPORT
SIG · PYTEST-RABBITMQ
P
pytest-rabbitmq
testingpythonv4.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pytest_rabbitmq
import pytest_rabbitmq
from pytest_rabbitmq import rabbitmq

Basic test using rabbitmq fixture to publish and consume a message. Ensure pytest-rabbitmq is in your test dependencies.

import pytest import os pytest_plugins = ['pytest_rabbitmq'] def test_publish_and_consume(rabbitmq): channel = rabbitmq.channel() channel.queue_declare(queue='test') channel.basic_publish(exchange='', routing_key='test', body='hello') method_frame, header_frame, body = channel.basic_get(queue='test') assert body == b'hello'
Debug
Known issues
breakingIn v4.0.0, the default fixture is async (aio-pika). Sync fixtures require explicit selection via pytest.mark.asyncio or using the sync client.
fix
If you need sync fixtures, install pika and use '--rabbitmq-client=pika' or use the 'rabbitmq_sync' fixture.
affects: >=4.0.0
deprecatedImporting from pytest_rabbitmq.factories is deprecated. Use top-level imports instead.
fix
Change 'from pytest_rabbitmq.factories import rabbitmq' to 'from pytest_rabbitmq import rabbitmq'.
affects: >=4.0.0
gotchaThe RabbitMQ process fixture downloads and manages a RabbitMQ server binary. Ensure port 5672 is available and the system has enough permissions to execute the binary.
fix
Set the environment variable RABBITMQ_SERVER_PATH to a pre-installed RabbitMQ server binary to avoid download.
affects: all
Upgrade
Version history
4.0.0latest on PyPI · released Mar 22, 2026
Audit
Dependencies
pytestrequiredCore dependency for pytest plugin
aio-pikaoptionalAsync RabbitMQ client used by default fixtures
pikaoptionalLegacy sync RabbitMQ client
Agent activity
12 hits · last 30 days
node
12
Resources
pytest-rabbitmq — pip install pytest-rabbitmq · libregistry