From 4e5bdca7f8227d10cae828f8064fb98190ace4aa Mon Sep 17 00:00:00 2001 From: pgjones Date: Thu, 29 Feb 2024 21:03:16 +0000 Subject: [PATCH] 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. --- tests/test_exceptions.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py index e4ee58633..91ad1a7ce 100644 --- a/tests/test_exceptions.py +++ b/tests/test_exceptions.py @@ -7,7 +7,7 @@ from werkzeug import exceptions from werkzeug.datastructures import Headers from werkzeug.datastructures import WWWAuthenticate -from werkzeug.exceptions import HTTPException +from werkzeug.exceptions import default_exceptions, HTTPException from werkzeug.wrappers import Response @@ -138,7 +138,7 @@ def test_retry_after_mixin(cls, value, expect): @pytest.mark.parametrize( "cls", sorted( - (e for e in HTTPException.__subclasses__() if e.code and e.code >= 400), + (e for e in default_exceptions.values() if e.code and e.code >= 400), key=lambda e: e.code, # type: ignore ), ) @@ -158,7 +158,7 @@ def test_description_none(): @pytest.mark.parametrize( "cls", sorted( - (e for e in HTTPException.__subclasses__() if e.code), + (e for e in default_exceptions.values() if e.code), key=lambda e: e.code, # type: ignore ), )