Skip to main content

Thin-wrapper around the mock package for easier use with pytest

Project description

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.

Project details


Download files

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

Source Distribution

pytest_mock-3.15.1.tar.gz (34.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_mock-3.15.1-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file pytest_mock-3.15.1.tar.gz.

File metadata

  • Download URL: pytest_mock-3.15.1.tar.gz
  • Upload date:
  • Size: 34.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pytest_mock-3.15.1.tar.gz
Algorithm Hash digest
SHA256 1849a238f6f396da19762269de72cb1814ab44416fa73a8686deac10b0d87a0f
MD5 5fb976ed4303e4f8132ed2367e297e31
BLAKE2b-256 6814eb014d26be205d38ad5ad20d9a80f7d201472e08167f0bb4361e251084a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_mock-3.15.1.tar.gz:

Publisher: deploy.yml on pytest-dev/pytest-mock

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytest_mock-3.15.1-py3-none-any.whl.

File metadata

  • Download URL: pytest_mock-3.15.1-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pytest_mock-3.15.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0a25e2eb88fe5168d535041d09a4529a188176ae608a6d249ee65abc0949630d
MD5 835fac1e7937671e1d94f8535b92e56b
BLAKE2b-256 5acc06253936f4a7fa2e0f48dfe6d851d9c56df896a9ab09ac019d70b760619c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_mock-3.15.1-py3-none-any.whl:

Publisher: deploy.yml on pytest-dev/pytest-mock

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page