File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -809,10 +809,12 @@ def __init__(
809
809
810
810
if response_wrapper in {None , Response }:
811
811
response_wrapper = TestResponse
812
- elif not isinstance (response_wrapper , TestResponse ):
812
+ elif response_wrapper is not None and not issubclass (
813
+ response_wrapper , TestResponse
814
+ ):
813
815
response_wrapper = type (
814
816
"WrapperTestResponse" ,
815
- (TestResponse , response_wrapper ), # type: ignore
817
+ (TestResponse , response_wrapper ),
816
818
{},
817
819
)
818
820
Original file line number Diff line number Diff line change 16
16
from werkzeug .test import EnvironBuilder
17
17
from werkzeug .test import run_wsgi_app
18
18
from werkzeug .test import stream_encode_multipart
19
+ from werkzeug .test import TestResponse
19
20
from werkzeug .utils import redirect
20
21
from werkzeug .wrappers import Request
21
22
from werkzeug .wrappers import Response
@@ -903,3 +904,24 @@ def test_no_content_type_header_addition():
903
904
c = Client (no_response_headers_app )
904
905
response = c .open ()
905
906
assert response .headers == Headers ([("Content-Length" , "8" )])
907
+
908
+
909
+ def test_client_response_wrapper ():
910
+ class CustomResponse (Response ):
911
+ pass
912
+
913
+ class CustomTestResponse (TestResponse , Response ):
914
+ pass
915
+
916
+ c1 = Client (Response (), CustomResponse )
917
+ r1 = c1 .open ()
918
+
919
+ assert isinstance (r1 , CustomResponse )
920
+ assert type (r1 ) is not CustomResponse # Got subclassed
921
+ assert issubclass (type (r1 ), CustomResponse )
922
+
923
+ c2 = Client (Response (), CustomTestResponse )
924
+ r2 = c2 .open ()
925
+
926
+ assert isinstance (r2 , CustomTestResponse )
927
+ assert type (r2 ) is CustomTestResponse # Did not get subclassed
You can’t perform that action at this time.
0 commit comments