--- id: pretend version: "1.0.9" license: BSD license_treatment: permissive maintenance: dormant --- # pretend — A library for stubbing in Python License: permissive · Maintenance: dormant · Downloads: 419.3K/mo ## 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 above — verify before relying. Pretend provides a lightweight library for creating stub objects in tests that return pre-canned responses without computation, plus utilities for recording calls and raising exceptions. 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 pip install pretend uv add pretend poetry add pretend ## Installing pretend 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: unspecified - Install friction: low - Maintenance: dormant - Downloads: 419.3K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags python stubbing library, test stub objects, mock alternatives, lightweight test doubles, stub creation testing, call recording test utility, pre-canned responses testing, test-doubles, stubbing [View on SkillFed](https://skillfed.io/packages/pretend) · [View on PyPI](https://pypi.org/project/pretend/)