You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
![]() |
3 weeks ago | |
---|---|---|
.github | 1 month ago | |
docs | 1 month ago | |
scripts | 10 months ago | |
src/pytest_mock | 2 months ago | |
tests | 2 months ago | |
.gitignore | 10 months ago | |
.pre-commit-config.yaml | 4 weeks ago | |
CHANGELOG.rst | 1 month ago | |
LICENSE | 4 years ago | |
README.rst | 4 months ago | |
RELEASING.rst | 7 months ago | |
mypy.ini | 7 months ago | |
setup.py | 1 month ago | |
tox.ini | 4 months ago |
README.rst
pytest-mock
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):
'os.remove')
mocker.patch('file')
UnixFS.rm('file') os.remove.assert_called_once_with(
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.