{"library":"pytest-stub","title":"pytest-stub","description":"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.","language":"python","status":"active","last_verified":"Mon Apr 27","install":{"commands":["pip install pytest-stub"],"cli":null},"imports":["from pytest_stub import stub"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import pytest\nfrom pytest_stub import stub\n\n@pytest.fixture\ndef stubbed_random():\n    with stub('random.randint') as m:\n        m.return_value = 42\n        yield\n\ndef test_random(stubbed_random):\n    import random\n    assert random.randint(1, 10) == 42","lang":"python","description":"Define a fixture that stubs `random.randint` to always return 42.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}