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
Built Distribution
File details
Details for the file pytest-mock-3.14.0.tar.gz
.
File metadata
- Download URL: pytest-mock-3.14.0.tar.gz
- Upload date:
- Size: 32.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.1 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2719255a1efeceadbc056d6bf3df3d1c5015530fb40cf347c0f9afac88410bd0 |
|
MD5 | c22f3c24300091f503258d1ba5159551 |
|
BLAKE2b-256 | c690a955c3ab35ccd41ad4de556596fa86685bf4fc5ffcc62d22d856cfd4e29a |
File details
Details for the file pytest_mock-3.14.0-py3-none-any.whl
.
File metadata
- Download URL: pytest_mock-3.14.0-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.1 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b72c38033392a5f4621342fe11e9219ac11ec9d375f8e2a0c164539e0d70f6f |
|
MD5 | d61798dcd70655d6e2b70937e39d34ad |
|
BLAKE2b-256 | f23bb26f90f74e2986a82df6e7ac7e319b8ea7ccece1caec9f8ab6104dc70603 |