{
  "id": "python/pytest-requests-mock-not-active",
  "signature": "requests.exceptions.ConnectionError: HTTPConnectionPool(host='api.example.com', port=80): Max retries exceeded",
  "signature_zh": "requests.exceptions.ConnectionError: HTTPConnectionPool(host='api.example.com', port=80): 超过最大重试次数",
  "regex": "requests\\.exceptions\\.ConnectionError:\\ HTTPConnectionPool\\(host='api\\.example\\.com',\\ port=80\\):\\ Max\\ retries\\ exceeded",
  "domain": "python",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "The test uses requests_mock but the mock is not active or does not match the request. This causes the real HTTP request to be attempted, leading to a connection error.",
  "root_cause_type": "generic",
  "root_cause_zh": "测试使用 requests_mock 但 mock 未激活或不匹配请求。这导致尝试真实的 HTTP 请求，从而引发连接错误。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This makes tests flaky and dependent on external services.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Mocks are synchronous; sleeping does not activate them.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This prevents the error but the test still fails because the request is not mocked.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.98,
      "how": "def test_api(requests_mock):\n    requests_mock.get('http://api.example.com/data', json={'key': 'value'})\n    response = requests.get('http://api.example.com/data')\n    assert response.json() == {'key': 'value'}",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.95,
      "how": "with requests_mock.Mocker() as m:\n    m.get('http://api.example.com/data', text='ok')\n    requests.get('http://api.example.com/data')",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Print the request URL in the test to ensure it matches the mock's URL.",
      "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.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-10-10",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}