{
  "id": "python/pytest-assertion-rewrite-missing",
  "signature": "assert 5 == 3 where 5 = func()",
  "signature_zh": "assert 5 == 3 where 5 = func()",
  "regex": "assert\\ 5\\ ==\\ 3\\ where\\ 5\\ =\\ func\\(\\)",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "pytest's assertion rewriting failed to produce detailed introspection because the test module was imported before the plugin registered, or the module is a plugin/entry-point not collected by pytest.",
  "root_cause_type": "generic",
  "root_cause_zh": "pytest 的断言重写未能生成详细的内部信息，因为测试模块在插件注册前被导入，或者该模块是未被 pytest 收集的插件/入口点。",
  "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": "Manual messages still hide the intermediate values of subexpressions, defeating the purpose of assertion rewriting.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Disabling plugins also disables assertion rewriting from the built-in plugin, making output worse.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Rename `checks.py` to `test_checks.py` and run `pytest test_checks.py -v`. Ensure no `conftest.py` imports the module early.",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "In `conftest.py`: `import pytest; pytest.register_assert_rewrite('myapp.tests.helpers')` then import helpers.",
      "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-03-12",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}