Skip to main content

pytest-mock

This plugin provides a mocker fixture which is a thin-wrapper around the patching API provided by the mock package:

import os

class UnixFS:

    @staticmethod
    def rm(filename):
        os.remove(filename)

def test_unix_fs(mocker):
    mocker.patch('os.remove')
    UnixFS.rm('file')
    os.remove.assert_called_once_with('file')

Besides undoing the mocking automatically after the end of the test, it also provides other nice utilities such as spy and stub, and uses pytest introspection when comparing calls.

python version anaconda docs ci coverage black pre-commit

Professionally supported pytest-mock is available.

Documentation

For full documentation, please see https://pytest-mock.readthedocs.io/en/latest.

License

Distributed under the terms of the MIT license.

Metadata

Release files for pytest-mock 3.16.1

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-mock 3.16.1
File Size Uploaded Provenance Actions
pytest_mock-3.16.1.tar.gz 41.1 kB With provenance Details for pytest_mock-3.16.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytest-mock 3.16.1
File Interpreter ABI Platform Actions
pytest_mock-3.16.1-py3-none-any.whl Python 3 none any Details for pytest_mock-3.16.1-py3-none-any.whl

Total release size: 52.2 kB

Release files / pytest_mock-3.16.1.tar.gz

Download URL pytest_mock-3.16.1.tar.gz
Size 41.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c6bf5fd123e9635471c63c46ee23044076b4a9f5fca2e39b11e468917c1199ec
BLAKE2b-256 checksum
How to use checksums
99f6e40a0a0abd8d6769531f63654a81529a98f1342a547173d4231a021ecfde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Release files / pytest_mock-3.16.1-py3-none-any.whl

Download URL pytest_mock-3.16.1-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cd162ca2495584a1fd854b4f80cfe520399a7654a462a42a84cd268844a9122b
BLAKE2b-256 checksum
How to use checksums
e2695941ea3bbd1bb48007767f6ef685c1996b016a4470328c26967aa69e4982
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Security for pytest-mock 3.16.1

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pytest_mock-3.16.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

3.16.1 This release

2 release files Full provenance

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