Skip to content

Commit

Permalink
Close AsyncClient properly in test_async_next_request (encode#1361)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchristie authored Oct 14, 2020
1 parent ca5f524 commit 07229b8
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tests/client/test_redirects.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,17 @@ def test_next_request():

@pytest.mark.usefixtures("async_environment")
async def test_async_next_request():
client = httpx.AsyncClient(transport=MockTransport(redirects))
request = client.build_request("POST", "https://example.org/redirect_303")
response = await client.send(request, allow_redirects=False)
assert response.status_code == httpx.codes.SEE_OTHER
assert response.url == "https://example.org/redirect_303"
assert response.next_request is not None

response = await client.send(response.next_request, allow_redirects=False)
assert response.status_code == httpx.codes.OK
assert response.url == "https://example.org/"
assert response.next_request is None
async with httpx.AsyncClient(transport=MockTransport(redirects)) as client:
request = client.build_request("POST", "https://example.org/redirect_303")
response = await client.send(request, allow_redirects=False)
assert response.status_code == httpx.codes.SEE_OTHER
assert response.url == "https://example.org/redirect_303"
assert response.next_request is not None

response = await client.send(response.next_request, allow_redirects=False)
assert response.status_code == httpx.codes.OK
assert response.url == "https://example.org/"
assert response.next_request is None


def test_head_redirect():
Expand Down

0 comments on commit 07229b8

Please sign in to comment.