{"id":27301,"library":"pytest-mockito","title":"pytest-mockito","description":"Base fixtures for using Mockito mocks with pytest. Integrates the Mockito library (a spy/mock framework) into pytest by providing fixtures that handle setup and teardown of mocks. Current version is 0.0.6.post1, with a slow release cadence.","status":"active","version":"0.0.6.post1","language":"python","source_language":"en","source_url":"https://github.com/kaste/pytest-mockito","tags":["pytest","mockito","mocking","testing"],"install":[{"cmd":"pip install pytest-mockito","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"Pytest plugin","package":"pytest","optional":false},{"reason":"Core mocking library","package":"mockito","optional":false}],"imports":[{"note":"mocker is a pytest fixture, not a direct import. Always use as a test function parameter.","wrong":"from pytest_mockito import mocker","symbol":"mocker","correct":"def test_foo(mocker): ..."}],"quickstart":{"code":"import pytest\nfrom mockito import when, verify\n\ndef test_example(mocker):\n    obj = {'foo': 'bar'}\n    when(obj).__getitem__('foo').thenReturn('mocked')\n    assert obj['foo'] == 'mocked'\n    verify(obj).__getitem__('foo')","lang":"python","description":"Basic test using the mocker fixture to reset mockito state automatically."},"warnings":[{"fix":"Add mocker as a parameter to your test function: def test_foo(mocker):","message":"The mocker fixture must be used in every test that uses Mockito mocks; otherwise, mock state leaks between tests.","severity":"gotcha","affected_versions":"all"},{"fix":"Use def test(mocker): ... and let pytest inject the fixture.","message":"Do not import mocker from pytest-mockito; it is a pytest fixture that must be injected by name.","severity":"gotcha","affected_versions":"all"},{"fix":"Pin mockito to version compatible with this plugin, or consider pytest-mock or unittest.mock.","message":"The package has seen no recent updates (last release 0.0.6.post1). It may rely on older versions of mockito. Check compatibility if using mockito 1.4+.","severity":"deprecated","affected_versions":">=0.0.6"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Change your test function to accept mocker as an argument: def test_foo(mocker):","cause":"Attempting to import mocker directly from the package instead of using it as a fixture parameter.","error":"NameError: name 'mocker' is not defined"},{"fix":"Remove the decorator; just add mocker as a parameter to the test function.","cause":"Using @pytest.mark.mocker decorator which does not exist; the fixture is only available as a function parameter.","error":"pytest.PytestUnknownMarkWarning: Unknown pytest.mark.mocker"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}