{
  "id": "python/pytest-caplog-propagation-disabled",
  "signature": "AssertionError: assert 'processing item' in ''\n  # caplog.text is empty",
  "signature_zh": "AssertionError: assert 'processing item' in ''\n  # caplog.text 为空",
  "regex": "AssertionError:\\ assert\\ 'processing\\ item'\\ in\\ ''\\\n\\ \\ \\#\\ caplog\\.text\\ is\\ empty",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "The application logger has propagate=False set (often to avoid duplicate handlers), so records never reach the root logger that caplog attaches its handler to. caplog captures nothing.",
  "root_cause_type": "generic",
  "root_cause_zh": "应用 logger 设置了 propagate=False（通常用于避免重复 handler），因此日志记录永远到不了 caplog 挂载 handler 的根 logger。caplog 捕获不到任何内容。",
  "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": "Level is not the problem; propagation is disabled so no records reach caplog regardless of level.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Logging handlers may not write to stderr, and the format is not the log message alone.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.92,
      "how": "def test_logs(caplog):\n    logger = logging.getLogger('myapp')\n    logger.propagate = True\n    with caplog.at_level(logging.INFO, logger='myapp'):\n        run()\n    assert 'processing item' in caplog.text",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "def test_logs(caplog):\n    logger = logging.getLogger('myapp')\n    logger.addHandler(caplog.handler)\n    try:\n        run()\n    finally:\n        logger.removeHandler(caplog.handler)\n    assert any('processing item' in r.message for r in caplog.records)",
      "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": "2024-09-27",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}