Skip to main content
https://img.shields.io/pypi/v/celery-mock.svg https://img.shields.io/travis/ulamlabs/celery-mock.svg https://codecov.io/gh/ulamlabs/celery-mock/branch/master/graph/badge.svg

celery-mock allows you to mock celery task and then run them when you want

Rationale

Sometimes a celery task retries itself to wait for some event or model to change. This is hard to test because celery tasks run (and retry) inline in tests. Now you can choose when to run your tasks.

Supported versions

  • Python 3 support

  • Celery 3.1.x and 4.0.x support

How to install

pip install celery-mock

How to use

from celery_mock import task_mock
from django.test import TestCase, Client

from myapp import dummyview

class UsersTestCase(TestCase):

    def test_create_user(self):
        client = Client()
        client.post('/api/users/', data={'username': 'konrad')  # runs tasks inline

        with task_mock():
            client.post('/api/users/', data={'username': 'konrad')
            # no tasks started yet
        # all tasks ran here

        with task_mock('myapp.post_user_create_task'):
            client.post('/api/users/', data={'username': 'konrad')
            # all tasks started execept myapp.post_user_create_task
        # myapp.post_user_create_task started here

        # you can use task_mock manually:

        tmock = task_mock().start()
        client.post('/api/users/', data={'username': 'konrad')
        # no tasks started yet
        tomock.stop()  # all tasks ran here

Metadata

Release files for celery-mock 1.1.7

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

Source distribution (sdist)

Source distribution for celery-mock 1.1.7
File Size Uploaded Provenance
celery-mock-1.1.7.tar.gz 4.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for celery-mock 1.1.7
File Interpreter ABI Platform
celery_mock-1.1.7-py3-none-any.whl Python 3 none any Details

Total release size: 10.2 kB

Release files / celery-mock-1.1.7.tar.gz

Download URL celery-mock-1.1.7.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a030b2e3a52165866c37a32f367404cffc65146fca802c713ef5663397795ffc
BLAKE2b-256 checksum
How to use checksums
8de3869393a2b70500dfbb156fb3440e5ee3d4a3b9d423fa1d03381b692a64a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.2 CPython/2.7.17 Darwin/19.6.0

Release files / celery_mock-1.1.7-py3-none-any.whl

Download URL celery_mock-1.1.7-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3fdcda1008e6c7451172523f8edb91d03cc225f28e996f5866a5c1ed532f93ac
BLAKE2b-256 checksum
How to use checksums
0cdf83f7ef312dac2ebd202a766646dfdc2eccb7054643e2c4ff12a076b752ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.2 CPython/2.7.17 Darwin/19.6.0

Security for celery-mock 1.1.7

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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