{
  "id": "python/pytest-warnings-as-errors-failure",
  "signature": "DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal",
  "signature_zh": "DeprecationWarning: datetime.datetime.utcnow() 已弃用并计划移除",
  "regex": "DeprecationWarning:\\ datetime\\.datetime\\.utcnow\\(\\)\\ is\\ deprecated\\ and\\ scheduled\\ for\\ removal",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "The test suite runs with -W error or filterwarnings=error, promoting a DeprecationWarning from application or third-party code into a test failure.",
  "root_cause_type": "generic",
  "root_cause_zh": "测试套件以 -W error 或 filterwarnings=error 运行，将应用或第三方代码的 DeprecationWarning 升级为测试失败。",
  "versions": [
    {
      "version": "3.12",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.13",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "noqa is for linters; pytest's warning filter isn't affected by inline noqa comments.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Doesn't fix the deprecated call; the warning still fires elsewhere in the codebase.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "from datetime import datetime, timezone\ndt = datetime.now(timezone.utc)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "# pyproject.toml\n[tool.pytest.ini_options]\nfilterwarnings = [\n  \"error\",\n  \"ignore::DeprecationWarning:legacy_lib.*\",\n  \"ignore:datetime.datetime.utcnow:DeprecationWarning\",\n]",
      "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.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-11-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}