pytest-stub is a plugin for the pytest framework that allows you to conveniently stub packages, modules, attributes, and functions for testing purposes. Version 1.1.0 is actively maintained. Release cadence is low, with occasional updates.
pip install pytest-stubVerified import paths — ran on the pinned version, not inferred.
Define a fixture that stubs `random.randint` to always return 42.
Use `with stub('...') as m:` inside a test or fixture.Only stub attributes reachable via a module path.
Upgrade to latest: `pip install --upgrade pytest-stub` and import `from pytest_stub import stub`.
Access the mock object via the context variable and set `.return_value`: e.g., `with stub('x') as m: m.return_value = 1`.No dependency data recorded yet.