api/Pytest-Mock

The Pytest-Mock library is a specialized plugin for the Pytest framework that provides a thin wrapper around the standard Python unittest.mock library. Its primary goal is to make Mocking more idiomatic and easier to manage within test suites. By utilizing the mocker fixture, developers can perform Patching without the boilerplate code often required by decorators or context managers.

Key features of Pytest-Mock include the automatic cleanup of mocks after each test, which prevents side effects from leaking into subsequent tests. It supports all standard unittest.mock functionalities, such as mocker.patch(), mocker.patch.object(), and mocker.Mock(). Furthermore, it offers unique utilities like mocker.spy() for tracking calls to existing functions and mocker.stub() for creating simple Stub-Objects. This makes it an essential tool for Unit-Testing and maintaining Software-Quality.

For more information, visit the Official Pytest-Mock GitHub Repository or the Official Documentation. The library is widely adopted in the Python community for its simplicity and robustness in Test-Driven-Development workflows.