{
  "id": "python/pytest-warnings-as-errors-failing-ci",
  "signature": "DeprecationWarning: datetime.datetime.utcnow() is deprecated\nFAILED tests/test_time.py::test_now - DeprecationWarning: ...",
  "signature_zh": "DeprecationWarning: datetime.datetime.utcnow() 已弃用\nFAILED tests/test_time.py::test_now - DeprecationWarning: ...",
  "regex": "DeprecationWarning:\\ datetime\\.datetime\\.utcnow\\(\\)\\ is\\ deprecated\\\nFAILED\\ tests/test_time\\.py::test_now\\ \\-\\ DeprecationWarning:\\ \\.\\.\\.",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "CI runs pytest with `-W error` (or `filterwarnings = error` in config), so any DeprecationWarning raised during test execution becomes a failure. This often appears after a Python minor upgrade.",
  "root_cause_type": "generic",
  "root_cause_zh": "CI 使用 `-W error`（或配置中的 `filterwarnings = error`）运行 pytest，因此测试执行期间抛出的任何 DeprecationWarning 都会变成失败。这通常在 Python 小版本升级后出现。",
  "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": "Hides all warnings, including ones the team intentionally turned into errors to catch regressions.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Only suppresses in that scope; other tests using the same deprecated API still fail.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Ignore specific known-safe warnings via pytest config:\n\n# pyproject.toml\n[tool.pytest.ini_options]\nfilterwarnings = [\n  \"error\",\n  \"ignore:datetime.datetime.utcnow\\(\\) is deprecated:DeprecationWarning\",\n]",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.98,
      "how": "Fix the deprecated call site:\n\nfrom datetime import datetime, timezone\ndatetime.now(timezone.utc)  # replaces utcnow()",
      "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-06-11",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}