pretend
A library for stubbing in Python
Decision gist · record as of 2026-08-14
Yes, if you prefer lightweight stubs over full mocking frameworks and your test suite targets Python versions the package supports. The library is dormant but stable, carries no known vulnerabilities, and has zero dependencies. However, verify compatibility with your Python version—classifiers only list up to 3.6, and the last release was 2018-04-14. If you need active maintenance or support for modern Python versions, consider alternatives.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Installation is straightforward with no runtime dependencies.
- The package is dormant (last release 2018-04-14, last commit 2024-06-22) but remains in production/stable status with no known vulnerabilities.
License · maintenance · safety
BSD (permissive) — BSD license (permissive) allows use in most projects with minimal restrictions; attribution is typically required but commercial and private use are permitted.
last release 2018-04-14 (3044 days) · last repo commit 2024-06-22 · 318 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 419,337 downloads/mo, #6,799 on PyPI
Alternatives
Verify before relying
pip install pretend
from pretend import stub, raiser, call_recorder
x = stub(country_code="US")
f = call_recorder(lambda a: a + 2)
result = f(3)
assert f.calls == [call(3)]- Whether the package remains compatible with Python versions released after 2018 despite classifiers only listing up to 3.6
- Whether dormant status means the package will receive security updates if vulnerabilities are discovered
What it is and what it does
Pretend is a test-focused library that makes it easy to create stub objects—objects that return fixed values rather than performing computation. Unlike mocking libraries, stubs are simpler and more focused: you define what attributes or methods return, and the stub returns exactly that. The library includes a stub() function to create objects with predefined attributes and methods, a raiser() helper to make stubs raise exceptions, and a call_recorder() utility to track how a stub was invoked.
The design philosophy emphasizes passing stubs as arguments to code under test rather than monkey-patching them globally. This encourages tests that verify computation results rather than implementation details. Pretend has no runtime dependencies and installs cleanly via pip, making it a minimal addition to a test suite.
Use it for
- Create test doubles with fixed return values to isolate code under test from external dependencies
- Stub methods that should raise exceptions to test error-handling paths without triggering real failures
- Record function calls during tests to verify a stub was invoked with expected arguments
- Replace real objects in unit tests with lightweight stubs that return pre-canned responses
- Test code that depends on external APIs by providing stub objects with fixed attributes
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you prefer lightweight stubs over full mocking frameworks and your test suite targets Python versions the package supports.
The library is dormant but stable, carries no known vulnerabilities, and has zero dependencies. However, verify compatibility with your Python version—classifiers only list up to 3.6, and the last release was 2018-04-14. If you need active maintenance or support for modern Python versions, consider alternatives.
Install
pretend on PyPI
Before you install
Installation is straightforward with no runtime dependencies. The package is dormant (last release 2018-04-14, last commit 2024-06-22) but remains in production/stable status with no known vulnerabilities.
License in practice
BSD license (permissive) allows use in most projects with minimal restrictions; attribution is typically required but commercial and private use are permitted.
Quickstart
pip install pretend
from pretend import stub, raiser, call_recorder
x = stub(country_code="US")
f = call_recorder(lambda a: a + 2)
result = f(3)
assert f.calls == [call(3)]
Verify before relying
- Whether the package remains compatible with Python versions released after 2018 despite classifiers only listing up to 3.6
- Whether dormant status means the package will receive security updates if vulnerabilities are discovered
Package facts
| License | BSD permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Dormant 3,044 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 419,337 / month, #6,799 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: Python :: 2.6Programming Language :: Python :: 2.7Programming Language :: Python :: 3.2Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Topic :: Software Development :: Testing |
Evidence: pretend-1.0.9-py2.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 › “python stubbing library”
- pretendPretend provides a lightweight library for creating stub objects in…
- mockitoMockito is a spying and stubbing framework for Python that lets you…
- stubsProvides a context-manager syntax for temporarily replacing function…
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 · mockito · pytest-stub · requests-mock · pytest-mock · placebo · urllib3-mock · pyfakefs · pip-install-test