# DeprecationWarning: 'pytest.warns(None)' is deprecated

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

## Root Cause

Using `pytest.warns(None)` to assert no warnings is deprecated since pytest 7; it now raises a warning that may be turned into an error.

## Version Compatibility

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

## Workarounds

1. **** (90% success)
   ```
   import warnings
with warnings.catch_warnings():
    warnings.simplefilter('error')
    my_function()
   ```
2. **** (85% success)
   ```
   with pytest.warns(UserWarning):
    my_function()
   ```

## Dead Ends

- **** — Hides the deprecation but does not fix the test logic; may break in future pytest versions. (70% fail)
- **** — Does not integrate with pytest's warning capture and may miss warnings from other threads. (60% fail)
