Skip to content

Commit

Permalink
Add test for Client.response_wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
jace committed Jan 8, 2024
1 parent 5a6f4dc commit 86f5f67
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/test_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from werkzeug.test import EnvironBuilder
from werkzeug.test import run_wsgi_app
from werkzeug.test import stream_encode_multipart
from werkzeug.test import TestResponse
from werkzeug.utils import redirect
from werkzeug.wrappers import Request
from werkzeug.wrappers import Response
Expand Down Expand Up @@ -903,3 +904,24 @@ def test_no_content_type_header_addition():
c = Client(no_response_headers_app)
response = c.open()
assert response.headers == Headers([("Content-Length", "8")])


def test_client_response_wrapper():
class CustomResponse(Response):
pass

class CustomTestResponse(TestResponse, Response):
pass

c1 = Client(Response(), CustomResponse)
r1 = c1.open()

assert isinstance(r1, CustomResponse)
assert type(r1) is not CustomResponse # Got subclassed
assert issubclass(type(r1), CustomResponse)

c2 = Client(Response(), CustomTestResponse)
r2 = c2.open()

assert isinstance(r2, CustomTestResponse)
assert type(r2) is CustomTestResponse # Did not get subclassed

0 comments on commit 86f5f67

Please sign in to comment.