{
  "id": "python/pytest-caplog-level-mismatch",
  "signature": "AssertionError: assert 0 == 1 in caplog.records for 'WARNING' level",
  "signature_zh": "断言错误：在 caplog.records 中，'WARNING' 级别的记录数断言 0 == 1",
  "regex": "AssertionError:\\ assert\\ 0\\ ==\\ 1\\ in\\ caplog\\.records\\ for\\ 'WARNING'\\ level",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The test uses caplog to check log messages but the logging level set in the code under test does not match the expected level, or the logger is not configured correctly.",
  "root_cause_type": "generic",
  "root_cause_zh": "测试使用 caplog 检查日志消息，但被测试代码中设置的日志级别与预期级别不匹配，或者记录器未正确配置。",
  "versions": [
    {
      "version": "3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Setting caplog.set_level(logging.DEBUG) globally may capture too many logs and mask the specific level issue.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Ignoring the level and checking for any log message may pass but does not validate the intended behavior.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.85,
      "how": "Set the logging level in the test using caplog.set_level(logging.WARNING) before calling the code, and ensure the code logs at that level.",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.8,
      "how": "Check the logger name in the code under test and configure caplog to capture logs from that specific logger: caplog.set_level(logging.WARNING, logger='my_logger')",
      "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.82,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-05-15",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}