{
  "id": "python/pytest-deprecationwarning-as-error",
  "signature": "DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version.\nE   DeprecationWarning: datetime.datetime.utcnow() is deprecated",
  "signature_zh": "DeprecationWarning: datetime.datetime.utcnow() 已弃用并计划在未来版本中移除。\nE   DeprecationWarning: datetime.datetime.utcnow() 已弃用",
  "regex": "DeprecationWarning:\\ datetime\\.datetime\\.utcnow\\(\\)\\ is\\ deprecated\\ and\\ scheduled\\ for\\ removal\\ in\\ a\\ future\\ version\\.\\\nE\\ \\ \\ DeprecationWarning:\\ datetime\\.datetime\\.utcnow\\(\\)\\ is\\ deprecated",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "pytest is configured with filterwarnings = error, turning DeprecationWarning into a test failure; the code or a dependency still calls utcnow().",
  "root_cause_type": "generic",
  "root_cause_zh": "pytest 配置了 filterwarnings = error，将 DeprecationWarning 变为测试失败；代码或依赖仍调用 utcnow()。",
  "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 all warnings and defeats the purpose; future breakages go unnoticed.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Ignores all deprecations including ones from your own code; not targeted.",
      "fail_rate": 0.55,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "from datetime import datetime, timezone\nnow = datetime.now(timezone.utc)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.8,
      "how": "# pytest.ini\n# filterwarnings =\n#   error\n#   ignore:datetime.datetime.utcnow:DeprecationWarning:legacy_lib",
      "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.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-09-11",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}