Comparison
kgb vs mockito vs pretend vs pytest-mock
Maintenance, adoption and momentum side by side, from PyPI, GitHub and deps.dev data refreshed every day.
Utilities for spying on function calls in unit tests.
Low maintenance activity. Last release 12 months ago, commits in 1 of the last 26 weeks. Weaker on commit activity and release cadence.
$
pip install kgbSpying framework
Maintained. Last release 8 months ago.
$
pip install mockitoA library for stubbing in Python
Likely abandoned. No release or commit for years (last release over 8 years ago).
$
pip install pretendThin-wrapper around the mock package for easier use with pytest
Actively maintained. Last release 7 weeks ago, commits in 21 of the last 26 weeks. A safe choice.
$
pip install pytest-mockIn short
- pretend looks abandoned: avoid it for new projects.
- pytest-mock is the most used: 92.1M downloads a month, 58× more than kgb.
- pytest-mock also has the best Pythie’s Index (77).
- Safe default for a new project: pytest-mock.
Side by side
| Metric | kgb | mockito | pretend | pytest-mock |
|---|---|---|---|---|
| Pythie’s Index | Pythie’s Index: 31 | 67 |