Skip to main content

Base fixtures for mockito

Project description

Convenience plugin on top of mockito.


pip install pytest-mockito

After that the plugin is enabled by default.


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):
    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

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 verifyNoUnwantedInteractions():


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pytest-mockito, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size pytest-mockito-0.0.4.tar.gz (3.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page