@@ -155,9 +155,7 @@ def test_elapsed_delay(server):
155155 assert response .elapsed .total_seconds () > 0.0
156156
157157
158- def test_wsgi_app_generator ():
159- def application (env , start_response ):
160- body = b"""
158+ _wsgi_body = b"""
161159
162160
163161<!DOCTYPE html>
@@ -170,10 +168,39 @@ def application(env, start_response):
170168 </body>
171169</html>
172170"""
171+
172+
173+ def test_wsgi_app ():
174+ def application (env , start_response ):
175+ start_response ("200 OK" , [("Content-Type" , "text/html" )])
176+ return [_wsgi_body ]
177+
178+ with httpx .Client (app = application ) as client :
179+ response = client .get ("http://example.com/" )
180+ assert response .status_code == 200
181+ assert b"This page deliberately left blank" in response .content
182+
183+
184+ def test_wsgi_app_generator ():
185+ def application (env , start_response ):
173186 start_response ("200 OK" , [("Content-Type" , "text/html" )])
174- for line in body .split (b"\n " ):
187+ for line in _wsgi_body .split (b"\n " ):
175188 yield line
176189
177190 with httpx .Client (app = application ) as client :
178191 response = client .get ("http://example.com/" )
192+ assert response .status_code == 200
179193 assert b"This page deliberately left blank" in response .content
194+
195+
196+ def test_wsgi_app_generator_empty ():
197+ def application (env , start_response ):
198+ body = [b"" , b"" , b"" ]
199+ start_response ("200 OK" , [("Content-Type" , "text/html" )])
200+ for line in body :
201+ yield line
202+
203+ with httpx .Client (app = application ) as client :
204+ response = client .get ("http://example.com/" )
205+ assert response .status_code == 200
206+ assert response .content == b""
0 commit comments