# pytest-dev/pytest-mock

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

Repository: https://github.com/pytest-dev/pytest-mock
Canonical: https://ross.abutalabs.com/products/pytest-mock
Homepage: https://pytest-mock.readthedocs.io/en/latest/
Language: Python
License: MIT
License Family: permissive
Topics: pytest, mock, hacktoberfest
Last push: 2026-08-25T09:56:02+00:00

## Health v2 (maintenance only)
Score: 77/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 99, release rhythm 36, longevity 100
- inputs: {"age_days": 4431, "days_push": 8, "days_rel": 351, "gap_med": 56.0, "n_releases_24m": 3}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 2039, forks 168 (observed 2026-08-28T04:06:08.305421+00:00)

## What it is
A pytest plugin that provides a `mocker` fixture wrapping the mock package's patching API. It automatically undoes mocks after each test and adds utilities like spy and stub with pytest-style introspection.

## Use cases
- mock functions in pytest tests
- patch os.remove in a unit test
- spy on method calls during testing
- create stubs for pytest test cases
- automatically undo patches after each test
- replace unittest.mock boilerplate in pytest

## When to choose
- you write tests with pytest and need mocking
- you want automatic patch cleanup between tests
- you prefer a fixture-based API over context managers and decorators

## When to avoid
- you don't use pytest as your test runner
- you need mocking features outside of pytest
- you already prefer raw unittest.mock with no wrapper

## Facets
- artifact type: plugin
- maturity: stable
- function: mocking, testing
- domain: testing, developer-tools
- platform: python, cli
- tags: pytest-plugin, pytest-fixture, test-doubles, spy, stub

## Member repositories
- pytest-dev/pytest-mock (main) score 77

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:06:08.305421+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T02:59:12.992536+00:00, confidence not recorded.
  - readme: https://github.com/pytest-dev/pytest-mock (fetched 2026-08-28T04:06:08.305421+00:00, sha 9548e72b99d2)
  - registry_pypi: https://pypi.org/pypi/pytest-mock/json (fetched 2026-08-29T10:39:15.122191+00:00, sha 0b8ac2b01ec6)
- Data as of 2026-08-30T08:39:29.467469+00:00.
