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

celery.contrib.testing.app

API Reference

Create Celery app instances used for testing.

celery.contrib.testing.app.DEFAULT_TEST_CONFIG = {u'enable_utc': True, u'worker_hijack_root_logger': False, u'timezone': u'UTC', u'accept_content': set([u'json']), u'worker_log_color': False, u'broker_url': u'memory://', u'result_backend': u'cache+memory://', u'broker_heartbeat': 0}

Contains the default configuration values for the test app.

celery.contrib.testing.app.TestApp(name=None, config=None, enable_logging=False, set_as_current=False, log=<class 'celery.contrib.testing.app.UnitLogging'>, backend=None, broker=None, **kwargs)[source]

App used for testing.

class celery.contrib.testing.app.Trap[source]

Trap that pretends to be an app but raises an exception instead.

This to protect from code that does not properly pass app instances, then falls back to the current_app.

class celery.contrib.testing.app.UnitLogging(*args, **kwargs)[source]

Sets up logging for the test application.

celery.contrib.testing.app.set_trap(*args, **kwds)[source]

Contextmanager that installs the trap app.

The trap means that anything trying to use the current or default app will raise an exception.

celery.contrib.testing.app.setup_default_app(*args, **kwds)[source]

Setup default app for testing.

Ensures state is clean after the test returns.