{
  "id": "python/pytest-caplog-no-output",
  "signature": "AssertionError: assert 'expected log' in ''",
  "signature_zh": "AssertionError: assert 'expected log' in ''",
  "regex": "AssertionError:\\ assert\\ 'expected\\ log'\\ in\\ ''",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "The logger's level is higher than the message level, or logging was configured with propagate=False, so caplog does not capture the record. caplog defaults to WARNING.",
  "root_cause_type": "generic",
  "root_cause_zh": "logger 的级别高于消息级别，或 logging 配置了 propagate=False，导致 caplog 无法捕获记录。caplog 默认级别为 WARNING。",
  "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": "-s disables output capture, which actually makes caplog less likely to see logs from some handlers.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "May add a handler but caplog still relies on propagation and its own level; often ineffective.",
      "fail_rate": 0.65,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.93,
      "how": "def test_logs(caplog):\n    caplog.set_level(logging.INFO, logger='app')\n    do_work()\n    assert 'expected log' in caplog.text\n\n# app/logger.py\nlogger = logging.getLogger('app')\nlogger.propagate = True",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "def test_logs(caplog):\n    caplog.set_level(logging.INFO)\n    do_work()\n    assert any(r.message == 'expected log' 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-04-11",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}