diff --git a/doc/background.rst b/doc/background.rst index 2c4d035..6d8f4fe 100644 --- a/doc/background.rst +++ b/doc/background.rst @@ -124,10 +124,10 @@ library added to the requirements, which may cause compatibility issues. Requirements version restrictions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -In general, the package requirements should have no version restrictions. For -example, the *werkzeug* library has no restrictions, which means that if a new -version comes out of it, it is assumed that *pytest-httpserver* will be able to -run with it. +In general, the package requirements should have as few version restrictions +as possible. The *werkzeug* library currently requires *werkzeug >= 3.0.0*, so +new versions of *werkzeug* are assumed to work with *pytest-httpserver*, +but older, unsupported versions are not. Many people uses this library in an environment having full of other packages and limiting version here will limit their versions in their requirements also. diff --git a/pytest_httpserver/httpserver.py b/pytest_httpserver/httpserver.py index 3691305..a1788ee 100644 --- a/pytest_httpserver/httpserver.py +++ b/pytest_httpserver/httpserver.py @@ -26,7 +26,6 @@ from typing import ClassVar from typing import TypedDict -import werkzeug.http from werkzeug import Request from werkzeug import Response from werkzeug.datastructures import Authorization @@ -152,10 +151,7 @@ def __init__(self, matchers: Mapping[str, Callable[[str | None, str], bool]] | N @staticmethod def authorization_header_value_matcher(actual: str | None, expected: str) -> bool: - func = getattr(Authorization, "from_header", None) - if func is None: # Werkzeug < 2.3.0 - func = werkzeug.http.parse_authorization_header # type: ignore[attr-defined] - return func(actual) == func(expected) # type: ignore + return Authorization.from_header(actual) == Authorization.from_header(expected) @staticmethod def default_header_value_matcher(actual: str | None, expected: str) -> bool: diff --git a/releasenotes/notes/remove-werkzeug-compat-be170cf610b27025.yaml b/releasenotes/notes/remove-werkzeug-compat-be170cf610b27025.yaml new file mode 100644 index 0000000..20ea855 --- /dev/null +++ b/releasenotes/notes/remove-werkzeug-compat-be170cf610b27025.yaml @@ -0,0 +1,8 @@ +--- +upgrade: + - | + Support for Werkzeug versions older than 3.0.0 has been removed as + pytest-httpserver now requires ``Werkzeug >= 3.0.0``. The fallback for + the deprecated ``werkzeug.http.parse_authorization_header`` has been + dropped from ``HeaderValueMatcher`` and the documentation has been + updated accordingly.