Skip to content

Commit 4e5bdca

Browse files
committed
Make the exception tests more robust
This should ensure that the tests work with Pytest 8 onwards. The issue appears to be that __subclasses__ "returns a list of all those references still alive." which could include the RequestRedirect. If it does include RequestRedirect the tests will fail as it requires an argument to be constructed. Note this test is not meant for RequestRedirect.
1 parent 70ad4d6 commit 4e5bdca

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/test_exceptions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from werkzeug import exceptions
88
from werkzeug.datastructures import Headers
99
from werkzeug.datastructures import WWWAuthenticate
10-
from werkzeug.exceptions import HTTPException
10+
from werkzeug.exceptions import default_exceptions, HTTPException
1111
from werkzeug.wrappers import Response
1212

1313

@@ -138,7 +138,7 @@ def test_retry_after_mixin(cls, value, expect):
138138
@pytest.mark.parametrize(
139139
"cls",
140140
sorted(
141-
(e for e in HTTPException.__subclasses__() if e.code and e.code >= 400),
141+
(e for e in default_exceptions.values() if e.code and e.code >= 400),
142142
key=lambda e: e.code, # type: ignore
143143
),
144144
)
@@ -158,7 +158,7 @@ def test_description_none():
158158
@pytest.mark.parametrize(
159159
"cls",
160160
sorted(
161-
(e for e in HTTPException.__subclasses__() if e.code),
161+
(e for e in default_exceptions.values() if e.code),
162162
key=lambda e: e.code, # type: ignore
163163
),
164164
)

0 commit comments

Comments
 (0)