Open pelson opened 3 years ago
Can confirm, the following doesn't work:
async def test_http_server_client_fetch(http_server_client):
resp = await http_server_client.fetch("/")
assert resp.code == 200
assert resp.body.decode("utf8") == MESSAGE
resp = await http_server_client.fetch("/redirect")
assert resp.effective_url == http_server_client.get_url("/")
assert resp.code == 200
assert resp.body.decode("utf8") == MESSAGE
But, the following works:
async def test_http_client_fetch(http_client, http_server, http_server_port):
url = "http://localhost:%s/" % http_server_port[1]
resp = await http_client.fetch(url)
assert resp.code == 200
assert resp.body.decode("utf8") == MESSAGE
url = "http://localhost:%s/redirect" % http_server_port[1]
resp = await http_client.fetch(url)
assert resp.effective_url == "http://localhost:%s/" % http_server_port[1]
assert resp.code == 200
assert resp.body.decode("utf8") == MESSAGE
I wanted to test that a redirect was setup correctly, so I went for something like:
But unfortunately the fetch call never returns. I suspect there is a deadlock somewhere.
For what it is worth, my workaround is to do something like: