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.
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)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest_mock-3.16.0.tar.gz | 35.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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 logRelease 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