--- id: stubs version: "1.0.0" license: Apache 2.0 license_treatment: permissive maintenance: abandoned --- # stubs — Tools for setting up stubs and mocks. License: permissive · Maintenance: abandoned · Downloads: 92.5K/mo ## What it is and what it does stubs is a lightweight testing utility that lets you temporarily replace a function's behavior using a context manager and matcher expressions. You define conditions (like `_ >= 3`) and specify what the function should return when those conditions are met, then wrap your test code in a `with` block that automatically reverts the stub when done. The package was designed for Python 3.4 and Python 3.5 and has not been maintained since its initial release in 2016-10-31. It has no external runtime dependencies, making installation trivial, but its age means you should verify compatibility with your current Python version before relying on it. Use it for: - Isolate a function's behavior in unit tests by returning fixed values when specific argument patterns match - Test code paths that depend on a function's return value without modifying the function itself - Verify that your code handles different function outputs correctly by stubbing responses for different input conditions - Temporarily replace functions during test runs without setting up a full mocking framework ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides a context-manager syntax for temporarily replacing function behavior with stub implementations that match specified conditions, reverting after the block exits. No. While the package is permissively licensed and has zero dependencies, it has been abandoned for over 3574 days with no updates since 2016-10-31. Unless you are maintaining legacy code that already uses stubs, you should choose a currently maintained alternative for new projects. ## Install pip install stubs uv add stubs poetry add stubs ## Installing stubs Before you install: Installation is frictionless with no runtime dependencies. However, the package has been abandoned since its only release on 2016-10-31 and has not been updated in over 3574 days, raising concerns about compatibility with modern Python versions. License in practice: Licensed under Apache 2.0 (permissive), so you can use, modify, and distribute the package freely in most contexts without restriction. Quickstart: pip install stubs from stubs import stub def f(x): return x * 2 with stub[f](_ >= 3) >> 5: print(f(3)) # prints 5 Package targets Python 3.4 and 3.5; compatibility with modern Python versions is unverified. Verify before relying: - Whether the package actually works with Python versions beyond 3.5 given its age and lack of updates - Whether the matcher syntax and context-manager API remain compatible with current testing frameworks - Real-world usage patterns and whether this approach is still considered idiomatic in modern Python testing ## Package facts - License: Apache 2.0 (permissive) - Python support: unspecified - Install friction: low - Maintenance: abandoned - Downloads: 92.5K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags function stubbing context manager, mock functions with conditions, temporary function replacement, stub testing python, conditional function mocking, matcher-based stubs, test double setup, abandoned, legacy-testing [View on SkillFed](https://skillfed.io/packages/stubs) · [View on PyPI](https://pypi.org/project/stubs/)