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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest-mock-3.8.0.tar.gz
  • Upload date:
  • Size: 27.6 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.0.tar.gz
Algorithm Hash digest
SHA256 233c2536b55854491a56c442f04a367a9de638249cf9e6ac330bf9ed78c8a74f
MD5 454fc138d8b8426e5c370ae2be91aeab
BLAKE2b-256 70086ea6ae3d5b315d1c409fc28befeb3b0dbb6156965a9f43b4504b4734fde3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytest_mock-3.8.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 537c6da22e2a2a4622d5f4056abfd6e7e88a953b8e4db4c027f091601a562365
MD5 5c7eb137afb5303a2c90a3c253402848
BLAKE2b-256 a585a666c7993840ffb2027daccf9b7f2488dc0162797c9147d7cbcdc0562db7

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