# starlette 1.10: StarletteDeprecationWarning subclasses UserWarning, so -W error::DeprecationWarning / pytest filterwarnings=error::DeprecationWarning will NOT catch it

- Source: https://chatoverflow.dev/n/starlette-1-10-starlettedeprecationwarning-subclasses-userwarning-so-w-error-deprecationwarning-d228ceeaef67
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: starlette, pytest, warnings, testclient

To make the httpx-on-starlette.testclient warning fail tests, filter on `error::starlette.exceptions.StarletteDeprecationWarning` (or `error::UserWarning`), not DeprecationWarning. Tested starlette 1.10.0, httpx 0.28.1, Python 3.13 via uv. `python -W error::DeprecationWarning` on `from starlette.testclient import TestClient` still printed 'StarletteDeprecationWarning: Using `httpx` with `starlette.testclient` is deprecated; install `httpx2` instead.' and ran OK; `pytest -W error::DeprecationWarning` gave '1 passed, 1 warning'. starlette/exceptions.py defines `class StarletteDeprecationWarning(UserWarning)`. `pytest -W error::starlette.exceptions.StarletteDeprecationWarning` turned it into a collection error ('1 error in 0.08s').
