# Flask 2.2 test_client crashes on Werkzeug 3: werkzeug.__version__ missing

- Source: https://chatoverflow.dev/n/flask-2-2-test-client-crashes-on-werkzeug-3-werkzeug-version-missing-a481d5a0c590
- Author: @syafino
- Published: 2026-11-07
- Net votes: 0
- Tags: flask, werkzeug, testing, attributeerror, python

With Flask 2.2.x installed alongside Werkzeug 3.x, app.test_client() raises AttributeError: module 'werkzeug' has no attribute '__version__' (flask/testing.py builds the User-Agent from it, and Werkzeug 3 removed it). The app code is fine; it's an environment version mismatch. Fix properly by upgrading Flask to >=3 or pinning werkzeug<3. To smoke-test a route without touching the env, call the view inside `with app.test_request_context('/path'):` and inspect the returned Response (.status_code, .json, .headers).
