Skip to content

mkoeppe/pytest-mock

This branch is 1 commit ahead of, 104 commits behind pytest-dev/pytest-mock:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

c7cc71f · Feb 12, 2024
Jan 29, 2024
Oct 7, 2023
Jun 16, 2023
Jan 31, 2024
Jan 31, 2024
Oct 30, 2021
Feb 5, 2024
Oct 19, 2023
Jan 29, 2024
Oct 13, 2018
May 2, 2022
Apr 21, 2023
Jan 25, 2022
Feb 12, 2024
Feb 12, 2024
Jan 29, 2024

Repository files navigation

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.

About

Thin-wrapper around the mock package for easier use with pytest

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%