Skip to content

Commit 67c927c

Browse files
committed
remove support for werkzeug < 2.3.0
1 parent 1568315 commit 67c927c

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

‎doc/background.rst‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ library added to the requirements, which may cause compatibility issues.
124124
Requirements version restrictions
125125
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
126126

127-
In general, the package requirements should have no version restrictions. For
128-
example, the *werkzeug* library has no restrictions, which means that if a new
129-
version comes out of it, it is assumed that *pytest-httpserver* will be able to
130-
run with it.
127+
In general, the package requirements should have as few version restrictions
128+
as possible. The *werkzeug* library currently requires *werkzeug >= 3.0.0*, so
129+
new versions of *werkzeug* are assumed to work with *pytest-httpserver*,
130+
but older, unsupported versions are not.
131131

132132
Many people uses this library in an environment having full of other packages
133133
and limiting version here will limit their versions in their requirements also.

‎pytest_httpserver/httpserver.py‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from typing import ClassVar
2727
from typing import TypedDict
2828

29-
import werkzeug.http
3029
from werkzeug import Request
3130
from werkzeug import Response
3231
from werkzeug.datastructures import Authorization
@@ -152,10 +151,7 @@ def __init__(self, matchers: Mapping[str, Callable[[str | None, str], bool]] | N
152151

153152
@staticmethod
154153
def authorization_header_value_matcher(actual: str | None, expected: str) -> bool:
155-
func = getattr(Authorization, "from_header", None)
156-
if func is None: # Werkzeug < 2.3.0
157-
func = werkzeug.http.parse_authorization_header # type: ignore[attr-defined]
158-
return func(actual) == func(expected) # type: ignore
154+
return Authorization.from_header(actual) == Authorization.from_header(expected)
159155

160156
@staticmethod
161157
def default_header_value_matcher(actual: str | None, expected: str) -> bool:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
upgrade:
3+
- |
4+
Support for Werkzeug versions older than 3.0.0 has been removed as
5+
pytest-httpserver now requires ``Werkzeug >= 3.0.0``. The fallback for
6+
the deprecated ``werkzeug.http.parse_authorization_header`` has been
7+
dropped from ``HeaderValueMatcher`` and the documentation has been
8+
updated accordingly.

0 commit comments

Comments
 (0)