This document describes the current stable version of pytest_celery (1.0). For development docs, go here.

pytest_celery.fixtures package

Submodules

pytest_celery.fixtures.backend module

Every backend component is added to the test matrix using the fixtures of this module.

These fixtures will configure the test setup for all supported celery backends by default. Every backend will be executed as a separate test case, and the test will be executed for each supported celery backend.

You may override these fixtures to customize the test setup for your specific needs.

pytest_celery.fixtures.backend.celery_backend(request: FixtureRequest) CeleryTestBackend[source]

Parameterized fixture for all supported celery backends. Responsible for tearing down the node.

This fixture will add parametrization to the test function, so that the test will be executed for each supported celery backend.

pytest_celery.fixtures.backend.celery_backend_cluster(celery_backend: CeleryTestBackend) CeleryBackendCluster[source]

Defines the cluster of backend nodes for the test. Responsible for tearing down the cluster.

To disable the cluster, override this fixture and return None.

Parameters:

celery_backend (CeleryTestBackend) – Parameterized fixture for all supported celery backends.

Returns:

Single node cluster for all supported celery backends.

Return type:

CeleryBackendCluster

pytest_celery.fixtures.backend.celery_backend_cluster_config(request: FixtureRequest) dict | None[source]

Attempts to compile the celery configuration from the cluster.

pytest_celery.fixtures.broker module

Every broker component is added to the test matrix using the fixtures of this module.

These fixtures will configure the test setup for all supported celery brokers by default. Every broker will be executed as a separate test case, and the test will be executed for each supported celery broker.

You may override these fixtures to customize the test setup for your specific needs.

pytest_celery.fixtures.broker.celery_broker(request: FixtureRequest) CeleryTestBroker[source]

Parameterized fixture for all supported celery brokers. Responsible for tearing down the node.

This fixture will add parametrization to the test function, so that the test will be executed for each supported celery broker.

pytest_celery.fixtures.broker.celery_broker_cluster(celery_broker: CeleryTestBroker) CeleryBrokerCluster[source]

Defines the cluster of broker nodes for the test. Responsible for tearing down the cluster.

It is not recommended to disable the broker cluster, but it can be done by overriding this fixture and returning None.

Parameters:

celery_broker (CeleryTestBroker) – Parameterized fixture for all supported celery brokers.

Returns:

Single node cluster for all supported celery brokers.

Return type:

CeleryBrokerCluster

pytest_celery.fixtures.broker.celery_broker_cluster_config(request: FixtureRequest) dict | None[source]

Attempts to compile the celery configuration from the cluster.

pytest_celery.fixtures.setup module

The test setup integrates all of the independent test components into a single entry point for the test.

This module provides the fixtures for the test setup, which will be used to prepare the environment for testing.

The test setup is automatically configured according to the individual components of the given architecture.

A test will be parametrized for each combination of supported celery backends, brokers, and workers in the test setup.

pytest_celery.fixtures.setup.celery_setup(celery_setup_cls: type[CeleryTestSetup], celery_worker_cluster: CeleryWorkerCluster, celery_broker_cluster: CeleryBrokerCluster, celery_backend_cluster: CeleryBackendCluster, celery_setup_app: Celery) CeleryTestSetup[source]

Prepares a celery setup ready for testing.

This fixture provides the entry point for a test. This fixture loads all components and immediately prepares the environment for testing.

Example

>>> def test_my_celery_setup(celery_setup: CeleryTestSetup):
...     assert celery_setup.ready()
...     # do some testing
pytest_celery.fixtures.setup.celery_setup_app(celery_setup_cls: type[CeleryTestSetup], celery_setup_config: dict, celery_setup_name: str) Celery[source]

Fixture interface to the API.

pytest_celery.fixtures.setup.celery_setup_cls() type[CeleryTestSetup][source]

The setup class to use for the test.

pytest_celery.fixtures.setup.celery_setup_config(celery_setup_cls: type[CeleryTestSetup], celery_worker_cluster_config: dict) dict[source]

Fixture interface to the API.

pytest_celery.fixtures.setup.celery_setup_name(celery_setup_cls: type[CeleryTestSetup]) str[source]

Fixture interface to the API.

pytest_celery.fixtures.worker module

The Built-in Celery Worker is added to the test matrix using the fixtures of this module.

These fixtures will configure the test setup for the built-in Celery worker by default.

You may override these fixtures to customize the test setup for your specific needs.

pytest_celery.fixtures.worker.celery_worker(request: FixtureRequest) CeleryTestWorker[source]

Parameterized fixture for all supported celery workers. Responsible for tearing down the node.

This fixture will add parametrization to the test function, so that the test will be executed for each supported celery worker.

pytest_celery.fixtures.worker.celery_worker_cluster(celery_worker: CeleryTestWorker) CeleryWorkerCluster[source]

Defines the cluster of worker nodes for the test. Responsible for tearing down the cluster.

To disable the cluster, override this fixture and return None.

Parameters:

celery_worker (CeleryTestWorker) – Parameterized fixture for all supported celery workers.

Returns:

Single node cluster for all supported celery workers.

Return type:

CeleryWorkerCluster

pytest_celery.fixtures.worker.celery_worker_cluster_config(celery_broker_cluster_config: dict, celery_backend_cluster_config: dict) dict[source]

Combine the broker and backend cluster configurations.

Additional configuration can be added.

Module contents