Skip to main content
https://raw.githubusercontent.com/dbfixtures/pytest-rabbitmq/master/logo.png

pytest-rabbitmq

Latest PyPI version Wheel Status Supported Python Versions License

What is this?

A pytest plugin for tests that require a running RabbitMQ broker. It provides process and client fixtures.

Project Architecture Diagram

How to use

The plugin contains two fixtures:

  • rabbitmq - it is a client fixture with function scope. After each test, it removes queues and exchanges created during the test to keep tests isolated and reliable.

  • rabbitmq_proc - a session-scoped fixture that starts a RabbitMQ instance at its first use and stops it at the end of the test session.

Simply include one of these fixtures in your test fixture list.

You can also create additional RabbitMQ client and process fixtures if you need to:

from pytest_rabbitmq import factories

rabbitmq_my_proc = factories.rabbitmq_proc(
    port=None)
rabbitmq_my = factories.rabbitmq('rabbitmq_my_proc')

Prerequisites

Install RabbitMQ on the machine where tests are executed. The plugin starts a local RabbitMQ process and uses rabbitmq-server and rabbitmqctl binaries.

By default, binary paths are set to typical Linux locations:

  • /usr/lib/rabbitmq/bin/rabbitmq-server

  • /usr/lib/rabbitmq/bin/rabbitmqctl

If your environment uses different paths, override them with fixture arguments, command-line options, or pytest.ini settings described below.

Quickstart: first test

Install the plugin:

pip install pytest-rabbitmq

Create a test that uses the built-in fixture:

def test_rabbitmq_fixture_available(rabbitmq):
    assert rabbitmq is not None

Run your tests:

pytest -q

Configuration

You can define settings in three ways: fixture factory argument, command-line option, and pytest.ini configuration option. You can pick which you prefer, but remember that these settings are handled in the following order:

  • Fixture factory argument

  • Command-line option

  • Configuration option in your pytest.ini file

Configuration options

RabbitMQ option

Fixture factory argument

Command-line option

pytest.ini option

Default

host

host

–rabbitmq-host

rabbitmq_host

127.0.0.1

RABBITMQ_NODE_PORT

port

–rabbitmq-port

rabbitmq_port

random

Port search count

–rabbitmq-port-search-count

rabbitmq_port_search_count

5

RABBITMQ_DIST_PORT

distribution_port

–rabbitmq-distribution-port

rabbitmq_distribution_port

random

rabbitmqctl path

ctl

–rabbitmq-ctl

rabbitmq_ctl

/usr/lib/rabbitmq/bin/rabbitmqctl

rabbitmq server path

server

–rabbitmq-server

rabbitmq_server

/usr/lib/rabbitmq/bin/rabbitmq-server

Plugin directory location

plugin_path

–rabbitmq-plugindir

rabbitmq_plugindir

$TMPDIR

Node name

node

–rabbitmq-node

rabbitmq_node

rabbitmq-test-{port}

Example usage:

  • Pass it as an argument in your own fixture.

    rabbitmq_proc = factories.rabbitmq_proc(port=8888)
  • Use the --rabbitmq-port command-line option when you run your tests.

    pytest tests --rabbitmq-port=8888
  • Specify your port as rabbitmq_port in your pytest.ini file.

    To do so, put a line like the following under the [pytest] section of your pytest.ini:

    [pytest]
    rabbitmq_port = 8888

Package resources

Metadata

Release files for pytest-rabbitmq 5.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-rabbitmq 5.0.0
File Size Uploaded
pytest_rabbitmq-5.0.0.tar.gz 15.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-rabbitmq 5.0.0
File Interpreter ABI Platform
pytest_rabbitmq-5.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 31.4 kB

Release files / pytest_rabbitmq-5.0.0.tar.gz

Download URL pytest_rabbitmq-5.0.0.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
8e74e42870602fb990b769745a58f8baf0e11263072d8f367375e3449b8e68b3
BLAKE2b-256 checksum
How to use checksums
7541f480875f03db9393aaca90b05eb39907639a1baad094c60420bc33d37682
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / pytest_rabbitmq-5.0.0-py3-none-any.whl

Download URL pytest_rabbitmq-5.0.0-py3-none-any.whl
Size 15.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
be1a64ca853db4fc6f1f831ff6246fa20e5df38eb73c7c2c9c8f4fc69ff969e8
BLAKE2b-256 checksum
How to use checksums
c4d1c350cadb574f7fd1fc35e894836c977035c624dc88226717bba05d365eb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

5.0.0 This release

2 release files

4.0.0

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.0

1 release file

2.0.1

1 release file

2.0.0

1 release file

1.1.2

1 release file

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.0.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page