MCPcopy
hub / github.com/encode/httpx / test_wsgi_server_port

Function test_wsgi_server_port

tests/test_wsgi.py:168–185  ·  view source on GitHub ↗

SERVER_PORT is populated correctly from the requested URL.

(url: str, expected_server_port: str)

Source from the content-addressed store, hash-verified

166 ],
167)
168def test_wsgi_server_port(url: str, expected_server_port: str) -> None:
169 """
170 SERVER_PORT is populated correctly from the requested URL.
171 """
172 hello_world_app = application_factory([b"Hello, World!"])
173 server_port: str | None = None
174
175 def app(environ, start_response):
176 nonlocal server_port
177 server_port = environ["SERVER_PORT"]
178 return hello_world_app(environ, start_response)
179
180 transport = httpx.WSGITransport(app=app)
181 client = httpx.Client(transport=transport)
182 response = client.get(url)
183 assert response.status_code == 200
184 assert response.text == "Hello, World!"
185 assert server_port == expected_server_port
186
187
188def test_wsgi_server_protocol():

Callers

nothing calls this directly

Calls 2

getMethod · 0.95
application_factoryFunction · 0.85

Tested by

no test coverage detected