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.
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
Release history Release notifications | RSS feed
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.2.tar.gz
(27.7 kB
view hashes)
Built Distribution
Close
Hashes for pytest_mock-3.8.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a9e226d6c0ef09fcf20c94eb3405c388af438a90f3e39687f84166da82d5948 |
|
MD5 | 3440f0ca6ddb5f22df13c3ce5d24b8f8 |
|
BLAKE2b-256 | 64ece21d6a5c31df566847de2dc7e7c1870c67cf10cb97cb0a1ea0e389446e60 |