mockito
Spying framework
Decision gist · record as of 2026-08-14
Yes. Mockito is a mature, actively maintained testing framework with zero dependencies, permissive licensing, and broad Python version support. It solves a core testing need—mocking and verification—with a clean API. No known vulnerabilities and low install friction make it a straightforward addition to any test suite.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python >=3.8
- Low friction: pure Python wheel with no runtime dependencies.
- Actively maintained with recent release (121 days ago).
License · maintenance · safety
MIT (permissive) — MIT license is permissive; you can use this freely in commercial and open-source projects with minimal restrictions.
last release 2026-04-15 (121 days)
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,570,213 downloads/mo, #3,750 on PyPI
Alternatives
Verify before relying
pip install mockito
from mockito import when, mock, unstub
import os
when(os.path).exists('/foo').thenReturn(True)
result = os.path.exists('/foo') # returns True
unstub()- Whether async/await support covers all common async testing patterns
- Performance characteristics when mocking large numbers of interactions
- Compatibility with popular test runners beyond pytest
What it is and what it does
Mockito is a mocking and spying framework for Python unit tests, originally inspired by the Java library of the same name. It lets you stub out method calls to return specific values, verify that functions were called with expected arguments, and replace real dependencies with controlled fakes during testing. The core workflow is straightforward: use `when()` to set up a stub that returns a value when called, use the stubbed code in your test, then call `unstub()` to clean up.
Version 2 adds first-class support for async/await, properties, descriptors, and ordered verification across multiple mocks. The framework handles context managers automatically, checking that stubs were actually used unless disabled. It has no runtime dependencies beyond Python itself, making it lightweight to add to any test suite.
Use it for
- Stub external API calls (e.g., requests library) to return fake responses without hitting the network
- Verify that your code calls a dependency with the correct arguments and number of times
- Mock filesystem operations (os.path.exists, open) to test error handling without touching disk
- Test async code by mocking async functions and verifying their call patterns
- Replace database queries with controlled mock responses to isolate unit tests from data layer
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Mockito is a mature, actively maintained testing framework with zero dependencies, permissive licensing, and broad Python version support. It solves a core testing need—mocking and verification—with a clean API. No known vulnerabilities and low install friction make it a straightforward addition to any test suite.
Install
mockito on PyPI
Before you install
Low friction: pure Python wheel with no runtime dependencies. Actively maintained with recent release (121 days ago). Supports Python >=3.8 and targets current Python versions.
Requires Python >=3.8
License in practice
MIT license is permissive; you can use this freely in commercial and open-source projects with minimal restrictions.
Quickstart
pip install mockito
from mockito import when, mock, unstub
import os
when(os.path).exists('/foo').thenReturn(True)
result = os.path.exists('/foo') # returns True
unstub()
Verify before relying
- Whether async/await support covers all common async testing patterns
- Performance characteristics when mocking large numbers of interactions
- Compatibility with popular test runners beyond pytest
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 121 days since the last release |
| First released | |
| Downloads | 1,570,213 / month, #3,750 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
Evidence: mockito-2.0.4-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “stubbing framework”
- mockitoMockito is a spying and stubbing framework for Python that lets you…
- stubsProvides a context-manager syntax for temporarily replacing function…
- pretendPretend provides a lightweight library for creating stub objects in…
Give your agent the search over MCP, or paste the wish link into any chat.
More Testing packages
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.
Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.
Install it if you want to measure test completeness or enforce coverage thresholds in your project.
pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.
Install it if you write tests for any asyncio-based code.
A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.
Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.
See also flexmock · stubs · pretend · pytest-stub · pytest-mock · requests-mock · types-mock · asyncmock · pip-install-test · pact-python