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

Function test_auth

tests/test_main.py:145–168  ·  view source on GitHub ↗
(server)

Source from the content-addressed store, hash-verified

143
144
145def test_auth(server):
146 url = str(server.url)
147 runner = CliRunner()
148 result = runner.invoke(httpx.main, [url, "-v", "--auth", "username", "password"])
149 print(result.output)
150 assert result.exit_code == 0
151 assert remove_date_header(splitlines(result.output)) == [
152 "* Connecting to '127.0.0.1'",
153 "* Connected to '127.0.0.1' on port 8000",
154 "GET / HTTP/1.1",
155 f"Host: {server.url.netloc.decode('ascii')}",
156 "Accept: */*",
157 "Accept-Encoding: gzip, deflate, br, zstd",
158 "Connection: keep-alive",
159 f"User-Agent: python-httpx/{httpx.__version__}",
160 "Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
161 "",
162 "HTTP/1.1 200 OK",
163 "server: uvicorn",
164 "content-type: text/plain",
165 "Transfer-Encoding: chunked",
166 "",
167 "Hello, world!",
168 ]
169
170
171def test_download(server):

Callers

nothing calls this directly

Calls 3

remove_date_headerFunction · 0.85
splitlinesFunction · 0.85
decodeMethod · 0.45

Tested by

no test coverage detected