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.14.1.tar.gz (33.2 kB view details)

Uploaded Source

Built Distribution

pytest_mock-3.14.1-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pytest_mock-3.14.1.tar.gz
Algorithm Hash digest
SHA256 159e9edac4c451ce77a5cdb9fc5d1100708d2dd4ba3c3df572f14097351af80e
MD5 f0cc01a3fdc4155b381ef73301d4776f
BLAKE2b-256 712867172c96ba684058a4d24ffe144d64783d2a270d0af0d9e792737bddc75c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_mock-3.14.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.14.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for pytest_mock-3.14.1-py3-none-any.whl
Algorithm Hash digest
SHA256 178aefcd11307d874b4cd3100344e7e2d888d9791a6a1d9bfe90fbc1b74fd1d0
MD5 38b4a9682e3316148c5a267a018c70ab
BLAKE2b-256 b20577b60e520511c53d1c1ca75f1930c7dd8e971d0c4379b7f4b3f9644685ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_mock-3.14.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 Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page