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.0

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.0
File Size Uploaded
pytest_mock-3.16.0.tar.gz 35.4 kB Details

Built distribution (wheel)

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

Total release size: 45.4 kB

Release files / pytest_mock-3.16.0.tar.gz

Download URL pytest_mock-3.16.0.tar.gz
Size 35.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5a8395528b8f498205f3718f575228d0edaed7425fff638f87d1a6c3e0383636
BLAKE2b-256 checksum
How to use checksums
7a7f6ed29931d5c8cd396e7c0a55412e6cc88020373365c8685985dea53d26d7
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 Sep 27, 2026.

Transparency log

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

Download URL pytest_mock-3.16.0-py3-none-any.whl
Size 10.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
007cfeb257801d88d9c0b2a7b5a15a15e73b71968dfd72e7bf8c4a2f8393aec8
BLAKE2b-256 checksum
How to use checksums
db5bb83a9bf1a3b4ec222f9fa083147ff6816245223da0ab92370e7e056f113f
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 Sep 27, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

3.16.0 This release

2 release files

3.15.1

2 release files

3.14.1

2 release files

3.14.0

2 release files

3.13.0

2 release files

3.12.0

2 release files

3.11.1

2 release files

3.11.0

2 release files

3.9.0

2 release files

3.8.2

2 release files

3.8.1

2 release files

3.8.0

2 release files

3.7.0

2 release files

3.6.1

2 release files

3.6.0

2 release files

3.5.1

2 release files

3.5.0

2 release files

3.4.0

2 release files

3.3.1

2 release files

3.3.0

2 release files

3.2.0

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.0.0

2 release files

1.12.1

2 release files

1.12.0

2 release files

1.11.2

2 release files

1.11.0

2 release files

1.10.4

2 release files

1.10.3

2 release files

1.10.2

2 release files

1.9.0

2 release files

1.8.0

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.3

2 release files

1.6.2

1 release file

1.6.1

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2

2 release files

1.1

2 release files

1.0

2 release files

0.11.0

2 release files

0.10.1

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.7.0

1 release file

0.6.0

1 release file

0.5.0

1 release file

0.4.3

1 release file

0.4.2

1 release file

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

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