-
Notifications
You must be signed in to change notification settings - Fork 140
Closed
Description
I was investigating #117 since i'm hit with that. But since code has been very much refactored, it doesn't make sense anymore. However something similar may remain.
The following test fails for example. I don't think the stream should remain in pool if start_tls raises.
@pytest.mark.anyio
@unittest.mock.patch("httpcore.backends.mock.AsyncMockStream.start_tls")
async def test_connection_pool_with_exception_on_start(start_tls_mock: unittest.mock.MagicMock):
"""
HTTP/1.1 requests that result in an exception should not be returned to the
connection pool.
"""
start_tls_mock.side_effect = Exception()
network_backend = AsyncMockBackend([b"Wait, this isn't valid HTTP!"])
async with AsyncConnectionPool(network_backend=network_backend) as pool:
# Sending an initial request, which once complete will not return to the pool.
with pytest.raises(Exception):
await pool.request(
"GET", "https://example.com/"
)
info = [repr(c) for c in pool.connections]
assert info == []
Metadata
Metadata
Assignees
Labels
No labels