# DeprecationWarning: datetime.datetime.utcnow() is deprecated
FAILED tests/test_time.py::test_now - DeprecationWarning: ...

- **ID:** `python/pytest-warning-as-error-unexpected`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## 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.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 7.x | active | — | — |
| 8.x | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   Narrow the error filter to your own package:
  [tool.pytest.ini_options]
  filterwarnings = [
    "error",
    "ignore::DeprecationWarning:thirdparty.module",
  ]
   ```
2. **** (95% success)
   ```
   Fix the offending call (e.g., replace datetime.utcnow() with datetime.now(timezone.utc)).
   ```

## Dead Ends

- **** — Loses the protective behavior across the whole suite; real deprecations go unnoticed. (60% fail)
- **** — Tedious and hides the root cause; new warnings still break CI unpredictably. (70% fail)
