{
  "id": "python/pytest-warning-as-error-failed",
  "signature": "Failed: [pytest] filterwarnings error in '...': DeprecationWarning: datetime.datetime.utcnow() is deprecated",
  "signature_zh": "Failed: [pytest] filterwarnings error in '...': DeprecationWarning: datetime.datetime.utcnow() 已弃用",
  "regex": "Failed:\\ \\[pytest\\]\\ filterwarnings\\ error\\ in\\ '\\.\\.\\.':\\ DeprecationWarning:\\ datetime\\.datetime\\.utcnow\\(\\)\\ is\\ deprecated",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "The project configures filterwarnings = error, turning warnings into failures. A third-party library or the code under test emits a DeprecationWarning that is not in the ignore list.",
  "root_cause_type": "generic",
  "root_cause_zh": "项目配置了 filterwarnings = error，将警告转为失败。第三方库或被测代码发出未在忽略列表中的 DeprecationWarning。",
  "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": "Reintroduces noisy warnings and hides genuine deprecations you wanted to catch.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Not applied in CI where the config is used; local passes but CI fails.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "[tool.pytest.ini_options]\nfilterwarnings = [\n  \"error\",\n  \"ignore:datetime.datetime.utcnow:DeprecationWarning\",\n  \"ignore:.*is deprecated:DeprecationWarning:thirdparty.module\",\n]",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.95,
      "how": "# before:\nfrom datetime import datetime\ndatetime.utcnow()\n\n# after:\nfrom datetime import datetime, timezone\ndatetime.now(timezone.utc)",
      "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-11-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}