{
  "id": "python/pytest-caplog-no-records",
  "signature": "AssertionError: assert 'user created' in ''\n +  where '' = caplog.text",
  "signature_zh": "AssertionError: assert 'user created' in ''\n +  其中 '' = caplog.text",
  "regex": "AssertionError:\\ assert\\ 'user\\ created'\\ in\\ ''\\\n\\ \\+\\ \\ where\\ ''\\ =\\ caplog\\.text",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "caplog captures records via the root logger handler, but the application logger has `propagate = False`, a custom handler with its own level, or the log level is higher than the emitted message.",
  "root_cause_type": "generic",
  "root_cause_zh": "caplog 通过根 logger 处理器捕获记录，但应用 logger 设置了 `propagate = False`、自定义处理器及级别，或日志级别高于所发出的消息。",
  "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 propagate=False, records never reach caplog's handler regardless of level.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "logger.info returns None; printing does not capture anything and the assertion still fails.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Force propagation and set level on the specific logger:\ndef test_create(caplog):\n    caplog.set_level(logging.INFO, logger='myapp.users')\n    create_user('alice')\n    assert 'user created' in caplog.text",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.82,
      "how": "If propagate is intentionally False, attach caplog's handler:\nlogger = logging.getLogger('myapp.users')\nlogger.addHandler(caplog.handler)\ncaplog.set_level(logging.INFO)",
      "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.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-05-19",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}