diff --git a/pyproject.toml b/pyproject.toml index 0cb10a58..99a9aef4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -104,6 +104,9 @@ exclude = [ [tool.uv] default-groups = ["dev", "pre-commit", "tests", "typing"] +[tool.uv.sources] +werkzeug = { path = "../werkzeug" } + [tool.pytest.ini_options] testpaths = ["tests"] filterwarnings = [ diff --git a/tests/test_basic.py b/tests/test_basic.py index c372a910..f8a11529 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -1,8 +1,8 @@ import gc +import importlib.metadata import re import typing as t import uuid -import warnings import weakref from contextlib import nullcontext from datetime import datetime @@ -1491,20 +1491,22 @@ def test_request_locals(): assert not flask.g +werkzeug_3_2 = importlib.metadata.version("werkzeug") >= "3.2." + + @pytest.mark.parametrize( - ("subdomain_matching", "host_matching", "expect_base", "expect_abc", "expect_xyz"), + ("subdomain_matching", "host_matching", "expect_subdomain", "expect_host"), [ - (False, False, "default", "default", "default"), - (True, False, "default", "abc", ""), - (False, True, "default", "abc", "default"), + (False, False, "default", "default"), + (True, False, "abc", ""), + (False, True, "abc", "default"), ], ) def test_server_name_matching( subdomain_matching: bool, host_matching: bool, - expect_base: str, - expect_abc: str, - expect_xyz: str, + expect_subdomain: str, + expect_host: str, ) -> None: app = flask.Flask( __name__, @@ -1522,15 +1524,18 @@ def test_server_name_matching( client = app.test_client() r = client.get(base_url="http://example.test") - assert r.text == expect_base + assert r.text == "default" r = client.get(base_url="http://abc.example.test") - assert r.text == expect_abc + assert r.text == expect_subdomain with pytest.warns() if subdomain_matching else nullcontext(): r = client.get(base_url="http://xyz.other.test") - assert r.text == expect_xyz + if werkzeug_3_2: + assert r.text == "default" + else: + assert r.text == expect_host def test_server_name_subdomain(): @@ -1566,12 +1571,12 @@ def test_server_name_subdomain(): rv = client.get("/", "https://dev.local") assert rv.data == b"default" - # suppress Werkzeug 0.15 warning about name mismatch - with warnings.catch_warnings(): - warnings.filterwarnings( - "ignore", "Current server name", UserWarning, "flask.app" - ) + with pytest.warns(match="Current server name"): rv = client.get("/", "http://foo.localhost") + + if werkzeug_3_2: + assert rv.status_code == 200 + else: assert rv.status_code == 404 rv = client.get("/", "http://foo.dev.local") @@ -1807,13 +1812,13 @@ def test_subdomain_matching_other_name(matching): def index(): return "", 204 - # suppress Werkzeug 0.15 warning about name mismatch - with warnings.catch_warnings(): - warnings.filterwarnings( - "ignore", "Current server name", UserWarning, "flask.app" - ) - # ip address can't match name + with pytest.warns(match="Current server name") if matching else nullcontext(): + # ip address can't match name, but will fall back to default rv = client.get("/", "http://127.0.0.1:3000/") + + if werkzeug_3_2: + assert rv.status_code == 204 + else: assert rv.status_code == 404 if matching else 204 # allow all subdomains if matching is disabled diff --git a/uv.lock b/uv.lock index 46c889d4..f145fc1c 100644 --- a/uv.lock +++ b/uv.lock @@ -463,7 +463,7 @@ requires-dist = [ { name = "jinja2", specifier = ">=3.1.2" }, { name = "markupsafe", specifier = ">=2.1.1" }, { name = "python-dotenv", marker = "extra == 'dotenv'" }, - { name = "werkzeug", specifier = ">=3.1.0" }, + { name = "werkzeug", directory = "../werkzeug" }, ] provides-extras = ["async", "dotenv"] @@ -1744,12 +1744,45 @@ wheels = [ [[package]] name = "werkzeug" -version = "3.1.5" -source = { registry = "https://pypi.org/simple" } +version = "3.2.0.dev0" +source = { directory = "../werkzeug" } dependencies = [ { name = "markupsafe" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/5a/70/1469ef1d3542ae7c2c7b72bd5e3a4e6ee69d7978fa8a3af05a38eca5becf/werkzeug-3.1.5.tar.gz", hash = "sha256:6a548b0e88955dd07ccb25539d7d0cc97417ee9e179677d22c7041c8f078ce67", size = 864754, upload-time = "2026-01-08T17:49:23.247Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/ad/e4/8d97cca767bcc1be76d16fb76951608305561c6e056811587f36cb1316a8/werkzeug-3.1.5-py3-none-any.whl", hash = "sha256:5111e36e91086ece91f93268bb39b4a35c1e6f1feac762c9c822ded0a4e322dc", size = 225025, upload-time = "2026-01-08T17:49:21.859Z" }, + +[package.metadata] +requires-dist = [ + { name = "markupsafe", specifier = ">=2.1.1" }, + { name = "watchdog", marker = "extra == 'watchdog'", specifier = ">=2.3" }, +] +provides-extras = ["watchdog"] + +[package.metadata.requires-dev] +dev = [ + { name = "ruff" }, + { name = "tox" }, + { name = "tox-uv" }, +] +docs = [ + { name = "pallets-sphinx-themes" }, + { name = "sphinx", specifier = "<9" }, + { name = "sphinxcontrib-log-cabinet" }, +] +docs-auto = [{ name = "sphinx-autobuild" }] +gha-update = [{ name = "gha-update", marker = "python_full_version >= '3.12'" }] +pre-commit = [ + { name = "pre-commit" }, + { name = "pre-commit-uv" }, +] +tests = [ + { name = "cffi" }, + { name = "cryptography" }, + { name = "ephemeral-port-reserve" }, + { name = "pytest" }, + { name = "pytest-timeout" }, + { name = "watchdog" }, +] +typing = [ + { name = "mypy" }, + { name = "pyright" }, ]