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.
Bruno Oliveira d01b267622
Merge pull request #309 from pytest-dev/pre-commit-ci-update-config
3 weeks ago
.github Upgrade GitHub Actions 1 month ago
docs Add docs/_static directory to allow sphinx-build to work without warnings 1 month ago
scripts Remove release title from the GitHub release notes body 10 months ago
src/pytest_mock add 3.7 support 2 months ago
tests [pre-commit.ci] pre-commit autoupdate (#300) 2 months ago
.gitignore Automate generating GitHub releases 10 months ago
.pre-commit-config.yaml [pre-commit.ci] pre-commit autoupdate 4 weeks ago
CHANGELOG.rst Fix formatting in CHANGELOG 1 month ago
LICENSE Run black and linting 4 years ago
README.rst [pre-commit.ci] auto fixes from pre-commit.com hooks 4 months ago
RELEASING.rst Drop Python 3.6, add support for 3.10 7 months ago
mypy.ini Configure asyncio_mode to fix tests 7 months ago
setup.py Remove unnecessary import 1 month ago
tox.ini Create sphinx documentation 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):
    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.