stubs

raw JSON →
1.0.0 verified Fri May 01 auth: no python

Tools for setting up stubs and mocks in Python tests. Version 1.0.0, currently at initial release with no defined release cadence.

pip install stubs
error AttributeError: module 'stubs' has no attribute 'Stub'
cause Improper import; using 'import stubs' then trying to access 'stubs.Stub'.
fix
Use 'from stubs import Stub'.
gotcha No known breaking changes as library is at version 1.0.0. However, the API is minimal; ensure you use the correct import path.
fix Use 'from stubs import Stub' instead of 'import stubs'.

Create a stub and set a return value for a method.

from stubs import Stub
stub = Stub()
stub.return_value('func', 42)
result = stub.func()
print(result)  # 42