Skip to content
Myr

test_timeouts.py

This file

Path

tests/test_timeouts.py

26 lines · 818 bytes · Python

Last changed by

Merge pull request #7 from encode/timeout-testsTom Christiebefore adoption34c03d7

History of this file

Take it

Merge pull request #7 from encode/timeout-testsTom Christiebefore adoption34c03d7

lines 1–26why, one step back
1import pytest
23import httpcore456@pytest.mark.asyncio7async def test_read_timeout(server):8 timeout = httpcore.TimeoutConfig(read_timeout=0.0001)910 async with httpcore.ConnectionPool(timeout=timeout) as http:11 with pytest.raises(httpcore.ReadTimeout):12 await http.request("GET", "http://127.0.0.1:8000/slow_response")131415@pytest.mark.asyncio16async def test_pool_timeout(server):17 timeout = httpcore.TimeoutConfig(pool_timeout=0.0001)18 limits = httpcore.PoolLimits(hard_limit=1)1920 async with httpcore.ConnectionPool(timeout=timeout, limits=limits) as http:21 response = await http.request("GET", "http://127.0.0.1:8000/", stream=True)2223 with pytest.raises(httpcore.PoolTimeout):24 await http.request("GET", "http://localhost:8000/")2526 await response.read()