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.8.1.tar.gz (27.7 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.8.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file pytest-mock-3.8.1.tar.gz.

File metadata

  • Download URL: pytest-mock-3.8.1.tar.gz
  • Upload date:
  • Size: 27.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for pytest-mock-3.8.1.tar.gz
Algorithm Hash digest
SHA256 2c6d756d5d3bf98e2e80797a959ca7f81f479e7d1f5f571611b0fdd6d1745240
MD5 dfb878ddc19e56ccd510ff1eed3a6ae9
BLAKE2b-256 78c2ff2327e36c93d950db089e308a38334717d3378c55afc8d95d1d23ade9c1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytest_mock-3.8.1-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for pytest_mock-3.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d989f11ca4a84479e288b0cd1e6769d6ad0d3d7743dcc75e460d1416a5f2135a
MD5 78cc6b045a15b89248af70278de1567a
BLAKE2b-256 c3ab76e3a40f0faea13806d0ac8e69b3903cfb7d76e49905a259c0465470963f

See more details on using hashes here.

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