# DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version.
E   DeprecationWarning: datetime.datetime.utcnow() is deprecated

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

## Root Cause

pytest is configured with filterwarnings = error, turning DeprecationWarning into a test failure; the code or a dependency still calls utcnow().

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   from datetime import datetime, timezone
now = datetime.now(timezone.utc)
   ```
2. **** (80% success)
   ```
   # pytest.ini
# filterwarnings =
#   error
#   ignore:datetime.datetime.utcnow:DeprecationWarning:legacy_lib
   ```

## Dead Ends

- **** — Hides all warnings and defeats the purpose; future breakages go unnoticed. (60% fail)
- **** — Ignores all deprecations including ones from your own code; not targeted. (55% fail)
