{
  "id": "python/pytest-mock-not-installed",
  "signature": "fixture 'mocker' not found\navailable fixtures: cache, capfd, capsys, ...",
  "signature_zh": "fixture 'mocker' 未找到\n可用 fixtures: cache, capfd, capsys, ...",
  "regex": "fixture\\ 'mocker'\\ not\\ found\\\navailable\\ fixtures:\\ cache,\\ capfd,\\ capsys,\\ \\.\\.\\.",
  "domain": "python",
  "category": "install_error",
  "subcategory": null,
  "root_cause": "The `mocker` fixture is provided by pytest-mock, which is not installed or not in the active environment.",
  "root_cause_type": "generic",
  "root_cause_zh": "`mocker` fixture 由 pytest-mock 提供，但未安装或不在当前激活的环境中。",
  "versions": [
    {
      "version": "3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.11",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "mock is a module, not a fixture; pytest tries to resolve it as a fixture and fails.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Returns the module, not a MagicMock controller; tests expecting `mocker.patch` fail with AttributeError.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "pytest runs in the currently active env; installing elsewhere doesn't make the fixture available.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.98,
      "how": "pip install pytest-mock\n# or\npoetry add --group dev pytest-mock\n# or\nuv add --dev pytest-mock",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "from unittest import mock\n\ndef test_x():\n    with mock.patch('myapp.views.requests.get') as m:\n        m.return_value.json.return_value = {}\n        myapp.views.fetch()",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-03-27",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}