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.0.tar.gz (33.8 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.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest_mock-3.15.0.tar.gz
  • Upload date:
  • Size: 33.8 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.0.tar.gz
Algorithm Hash digest
SHA256 ab896bd190316b9d5d87b277569dfcdf718b2d049a2ccff5f7aca279c002a1cf
MD5 006f31ecad87857c23c4df6eb7ee9b71
BLAKE2b-256 61993323ee5c16b3637b4d941c362182d3e749c11e400bea31018c42219f3a98

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pytest_mock-3.15.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ef2219485fb1bd256b00e7ad7466ce26729b30eadfc7cbcdb4fa9a92ca68db6f
MD5 d4fe3980be4341d3abe068ba9251d363
BLAKE2b-256 2bb37fefc43fb706380144bcd293cc6e446e6f637ddfa8b83f48d1734156b529

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_mock-3.15.0-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