{
  "id": "python/pytest-assertion-introspection-disabled",
  "signature": "AssertionError: assert False\n +  where False = <built-in method __eq__ of type object at 0x...>(1, 2)\n# note: assertion rewriting is disabled; enable with --assert=rewrite",
  "signature_zh": "AssertionError: assert False\n +  其中 False = <built-in method __eq__ of type object at 0x...>(1, 2)\n# 注意：断言重写已禁用；使用 --assert=rewrite 启用",
  "regex": "AssertionError:\\ assert\\ False\\\n\\ \\+\\ \\ where\\ False\\ =\\ <built\\-in\\ method\\ __eq__\\ of\\ type\\ object\\ at\\ 0x\\.\\.\\.>\\(1,\\ 2\\)\\\n\\#\\ note:\\ assertion\\ rewriting\\ is\\ disabled;\\ enable\\ with\\ \\-\\-assert=rewrite",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "pytest's assertion rewriting is disabled, either because --assert=plain was passed, the test module was imported via importlib without pytest's meta path finder, or PYTEST_DISABLE_PLUGIN_AUTOLOAD interfered.",
  "root_cause_type": "generic",
  "root_cause_zh": "pytest 的断言重写被禁用，可能是因为传入了 --assert=plain、测试模块通过 importlib 导入而未经过 pytest 的 meta path finder，或 PYTEST_DISABLE_PLUGIN_AUTOLOAD 干扰。",
  "versions": [
    {
      "version": "6.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "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": "Verbosity increases output but does not re-enable assertion rewriting; the useful diff remains missing.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Manual prints work but clutter tests and don't restore pytest's rich introspection for all assertions.",
      "fail_rate": 0.65,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "# pytest.ini\n[pytest]\naddopts = --assert=rewrite\n# verify with: pytest --version -v | grep assertion",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "# Instead of: import tests.test_foo\n# Run: pytest tests/test_foo.py\n# and remove any `importlib.import_module('tests.test_foo')` from conftest.py",
      "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.83,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-08-02",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}