{
  "id": "python/pytest-deprecation-warning-as-error",
  "signature": "DeprecationWarning: 'pytest.warns(None)' is deprecated",
  "signature_zh": "DeprecationWarning: 'pytest.warns(None)' 已弃用",
  "regex": "DeprecationWarning:\\ 'pytest\\.warns\\(None\\)'\\ is\\ deprecated",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Using `pytest.warns(None)` to assert no warnings is deprecated since pytest 7; it now raises a warning that may be turned into an error.",
  "root_cause_type": "generic",
  "root_cause_zh": "使用 `pytest.warns(None)` 断言无警告自 pytest 7 起已弃用；它现在会引发警告，可能被转换为错误。",
  "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": "Hides the deprecation but does not fix the test logic; may break in future pytest versions.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Does not integrate with pytest's warning capture and may miss warnings from other threads.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "import warnings\nwith warnings.catch_warnings():\n    warnings.simplefilter('error')\n    my_function()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "with pytest.warns(UserWarning):\n    my_function()",
      "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-02-14",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}