{
  "id": "python/pytest-warning-as-error-unexpected",
  "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": "pytest.ini or pyproject.toml has `filterwarnings = error`, converting warnings to failures. A transitive dependency or stdlib call emits a warning that was previously ignored.",
  "root_cause_type": "generic",
  "root_cause_zh": "pytest.ini 或 pyproject.toml 设置了 `filterwarnings = error`，将警告转为失败。某个传递依赖或标准库调用发出之前被忽略的警告。",
  "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": "Loses the protective behavior across the whole suite; real deprecations go unnoticed.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Tedious and hides the root cause; new warnings still break CI unpredictably.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Narrow the error filter to your own package:\n  [tool.pytest.ini_options]\n  filterwarnings = [\n    \"error\",\n    \"ignore::DeprecationWarning:thirdparty.module\",\n  ]",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Fix the offending call (e.g., replace datetime.utcnow() with datetime.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-07-14",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}