Skip to content
Myr

Add test for HEAD redirect behavior (#1184)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Florimond Manca · committed by GitHub · parent a226c60 · Browse files · 1 file+17 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+17 added−1 removed

  • tests:+17 added−1 removed

1 file+17 added−1 removed

modified:tests/client/test_redirects.py+17 added-1 removed
158 unmodified lines
159 headers,160 ByteStream(b""),161 )162163 return b"HTTP/1.1", 200, b"OK", [], ByteStream(b"Hello, world!")163 stream = ByteStream(b"Hello, world!") if method != b"HEAD" else ByteStream(b"")164165 return b"HTTP/1.1", 200, b"OK", [], stream166167168class AsyncMockTransport(MockTransport, httpcore.AsyncHTTPTransport):169 async def request(170 self, *args, **kwargs171 ) -> typing.Tuple[
65 unmodified lines
237 assert response.is_redirect is False238 assert len(response.history) == 1239240241@pytest.mark.asyncio242async def test_head_redirect():243 """244 Contrary to Requests, redirects remain enabled by default for HEAD requests.245 """246 client = AsyncClient(transport=AsyncMockTransport())247 response = await client.head("https://example.org/redirect_302")248 assert response.status_code == codes.OK249 assert response.url == URL("https://example.org/")250 assert response.request.method == "HEAD"251 assert len(response.history) == 1252 assert response.text == ""253254255@pytest.mark.usefixtures("async_environment")256async def test_relative_redirect():257 client = AsyncClient(transport=AsyncMockTransport())258 response = await client.get("https://example.org/relative_redirect")
260 unmodified lines