{
  "id": "python/pytest-caplog-empty-handler",
  "signature": "assert 0 == 1\n +  where 0 = len(caplog.records)",
  "signature_zh": "assert 0 == 1\n +  where 0 = len(caplog.records)",
  "regex": "assert\\ 0\\ ==\\ 1\\\n\\ \\+\\ \\ where\\ 0\\ =\\ len\\(caplog\\.records\\)",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "caplog fixture captures logs at WARNING level by default; if the logger propagates=False or the log level is INFO, records are not captured.",
  "root_cause_type": "generic",
  "root_cause_zh": "caplog fixture 默认捕获 WARNING 级别的日志；如果 logger 的 propagate=False 或日志级别为 INFO，则记录不会被捕获。",
  "versions": [
    {
      "version": "7.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "8.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "If the logger has `propagate = False`, records never reach the root handler that caplog attaches to.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Loses structured logging and doesn't test the actual logging behavior.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "`caplog.set_level(logging.INFO, logger='mylogger')` and ensure `logging.getLogger('mylogger').propagate = True`",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "with caplog.at_level(logging.INFO):\n    myfunc()\nassert 'expected' in caplog.text",
      "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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-14",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}