Skip to main content

Convenience plugin on top of mockito.

https://img.shields.io/github/actions/workflow/status/kaste/pytest-mockito/ci.yml?branch=master

Install

pip install pytest-mockito

After that the plugin is enabled by default.

Fixtures

The plugin provides fixtures for the main entrypoints of mockito which guarantee that you unstub() on teardown. Usage is very simple and straightforward:

def test_foo(when):
    when(os.path).exists('/foo').thenReturn(False)
    assert os.path.exists('/foo')  # sic!
    # will still unstub/unpatch bc pytest will run the teardown

For convenience verifyStubbedInvocationsAreUsed is called just before unstub. This should warn you when you setup stubs that you actually don’t use.

You can also use a marker. usefixtures here will ensure an unstub at the end of each test, but does not actually inject the fixture:

import pytest

@pytest.mark.usefixtures('unstub')
class TestDog:
    def test(self):
        ...

To mark all test cases at the module level:

pytestmark = pytest.mark.usefixtures('unstub')

All of the following fixtures just export the equivalent mockito function but unstub() on teardown. The exception here is expect which also calls verifyExpectedInteractions():

when
when2
expect
patch
unstub
spy2

Metadata

Release files for pytest-mockito 0.0.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 pytest-mockito 0.0.7
File Size Uploaded Provenance Actions
pytest_mockito-0.0.7.tar.gz 3.8 kB Without provenance Details for pytest_mockito-0.0.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytest-mockito 0.0.7
File Interpreter ABI Platform Actions
pytest_mockito-0.0.7-py3-none-any.whl Python 3 none any Details for pytest_mockito-0.0.7-py3-none-any.whl

Total release size: 7.7 kB

Release files / pytest_mockito-0.0.7.tar.gz

Download URL pytest_mockito-0.0.7.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
1763527520b2a0c7f25a91e1c2afa56ed44c4637ca163aa1ed65ef3bb67795bc
BLAKE2b-256 checksum
How to use checksums
c586139eeb78c390043cb7c8d87c59c3e351f9b8f40250dbc5fd018f2e2b6fa3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / pytest_mockito-0.0.7-py3-none-any.whl

Download URL pytest_mockito-0.0.7-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78f8d9ee597603ba44a337316ede84a959f8e013670b3bf0a5ab2647c76cc453
BLAKE2b-256 checksum
How to use checksums
f4830a2b147e8fb773330cdc7103578f704cc6c49b2267e16a5fc5f34a1bb4d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for pytest-mockito 0.0.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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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