contrib.pytest

Fixtures and testing utilities for :pypi:`py.test <pytest>`.

Module Contents

Functions

_create_app(enable_logging=False,use_trap=False,parameters=dict,**config) Utility context used to setup Celery app for pytest fixtures.
use_celery_app_trap() You can override this fixture to enable the app trap.
celery_session_app(request,celery_config,celery_parameters,celery_enable_logging,use_celery_app_trap) Session Fixture: Return app for session fixtures.
celery_session_worker(request,celery_session_app,celery_includes,celery_worker_pool,celery_worker_parameters) Session Fixture: Start worker that lives throughout test suite.
celery_enable_logging() You can override this fixture to enable logging.
celery_includes() You can override this include modules when a worker start.
celery_worker_pool() You can override this fixture to set the worker pool.
celery_config() Redefine this fixture to configure the test Celery app.
celery_parameters() Redefine this fixture to change the init parameters of test Celery app.
celery_worker_parameters() Redefine this fixture to change the init parameters of Celery workers.
celery_app(request,celery_config,celery_parameters,celery_enable_logging,use_celery_app_trap) Fixture creating a Celery application instance.
celery_worker(request,celery_app,celery_includes,celery_worker_pool,celery_worker_parameters) Fixture: Start worker in a thread, stop it when the test returns.
depends_on_current_app(celery_app) Fixture that sets app as current.
_create_app(enable_logging=False, use_trap=False, parameters=dict, **config)

Utility context used to setup Celery app for pytest fixtures.

use_celery_app_trap()

You can override this fixture to enable the app trap.

The app trap raises an exception whenever something attempts to use the current or default apps.

celery_session_app(request, celery_config, celery_parameters, celery_enable_logging, use_celery_app_trap)

Session Fixture: Return app for session fixtures.

celery_session_worker(request, celery_session_app, celery_includes, celery_worker_pool, celery_worker_parameters)

Session Fixture: Start worker that lives throughout test suite.

celery_enable_logging()

You can override this fixture to enable logging.

celery_includes()

You can override this include modules when a worker start.

You can have this return a list of module names to import, these can be task modules, modules registering signals, and so on.

celery_worker_pool()

You can override this fixture to set the worker pool.

The “solo” pool is used by default, but you can set this to return e.g. “prefork”.

celery_config()

Redefine this fixture to configure the test Celery app.

The config returned by your fixture will then be used to configure the celery_app() fixture.

celery_parameters()

Redefine this fixture to change the init parameters of test Celery app.

The dict returned by your fixture will then be used as parameters when instantiating Celery.

celery_worker_parameters()

Redefine this fixture to change the init parameters of Celery workers.

This can be used e. g. to define queues the worker will consume tasks from.

The dict returned by your fixture will then be used as parameters when instantiating WorkController.

celery_app(request, celery_config, celery_parameters, celery_enable_logging, use_celery_app_trap)

Fixture creating a Celery application instance.

celery_worker(request, celery_app, celery_includes, celery_worker_pool, celery_worker_parameters)

Fixture: Start worker in a thread, stop it when the test returns.

depends_on_current_app(celery_app)

Fixture that sets app as current.