============================= test session starts ============================== platform linux -- Python 3.10.1, pytest-6.2.5, py-1.11.0, pluggy-0.13.1 rootdir: /build/python-httpcore/src/httpcore-0.14.3, configfile: setup.cfg plugins: trio-0.7.0, httpbin-1.0.0, anyio-3.5.0, asyncio-0.16.0 collected 124 items tests/test_api.py .127.0.0.1 - - [17/Jan/2022 07:33:26] "GET / HTTP/1.1" 200 12144 .. [ 2%] tests/test_models.py ............. [ 12%] tests/_async/test_connection.py ....FF...... [ 22%] tests/_async/test_connection_pool.py ................... [ 37%] tests/_async/test_http11.py .............. [ 49%] tests/_async/test_http2.py FFFFFFFFFFFFFF [ 60%] tests/_async/test_http_proxy.py ...... [ 65%] tests/_async/test_integration.py ...... [ 70%] tests/_sync/test_connection.py ..F... [ 75%] tests/_sync/test_connection_pool.py ........... [ 83%] tests/_sync/test_http11.py ....... [ 89%] tests/_sync/test_http2.py FFFFFFF [ 95%] tests/_sync/test_http_proxy.py ... [ 97%] tests/_sync/test_integration.py ... [100%] =================================== FAILURES =================================== ________________________ test_http2_connection[asyncio] ________________________ @pytest.mark.anyio async def test_http2_connection(): origin = Origin(b"https", b"example.com", 443) network_backend = AsyncMockBackend( [ hyperframe.frame.SettingsFrame().serialize(), hyperframe.frame.HeadersFrame( stream_id=1, data=hpack.Encoder().encode( [ (b":status", b"200"), (b"content-type", b"plain/text"), ] ), flags=["END_HEADERS"], ).serialize(), hyperframe.frame.DataFrame( stream_id=1, data=b"Hello, world!", flags=["END_STREAM"] ).serialize(), ], http2=True, ) async with AsyncHTTPConnection( origin=origin, network_backend=network_backend, http2=True ) as conn: > response = await conn.request("GET", "https://example.com/") tests/_async/test_connection.py:103: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ httpcore/_async/interfaces.py:41: in request response = await self.handle_async_request(request) httpcore/_async/connection.py:90: in handle_async_request raise exc httpcore/_async/connection.py:75: in handle_async_request from .http2 import AsyncHTTP2Connection _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ import enum import time import types import typing > import h2.config E ModuleNotFoundError: No module named 'h2' httpcore/_async/http2.py:6: ModuleNotFoundError _________________________ test_http2_connection[trio] __________________________ @pytest.mark.anyio async def test_http2_connection(): origin = Origin(b"https", b"example.com", 443) network_backend = AsyncMockBackend( [ hyperframe.frame.SettingsFrame().serialize(), hyperframe.frame.HeadersFrame( stream_id=1, data=hpack.Encoder().encode( [ (b":status", b"200"), (b"content-type", b"plain/text"), ] ), flags=["END_HEADERS"], ).serialize(), hyperframe.frame.DataFrame( stream_id=1, data=b"Hello, world!", flags=["END_STREAM"] ).serialize(), ], http2=True, ) async with AsyncHTTPConnection( origin=origin, network_backend=network_backend, http2=True ) as conn: > response = await conn.request("GET", "https://example.com/") tests/_async/test_connection.py:103: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ httpcore/_async/interfaces.py:41: in request response = await self.handle_async_request(request) httpcore/_async/connection.py:90: in handle_async_request raise exc httpcore/_async/connection.py:75: in handle_async_request from .http2 import AsyncHTTP2Connection _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ import enum import time import types import typing > import h2.config E ModuleNotFoundError: No module named 'h2' httpcore/_async/http2.py:6: ModuleNotFoundError ________________________ test_http2_connection[asyncio] ________________________ @pytest.mark.anyio async def test_http2_connection(): origin = Origin(b"https", b"example.com", 443) stream = AsyncMockStream( [ hyperframe.frame.SettingsFrame().serialize(), hyperframe.frame.HeadersFrame( stream_id=1, data=hpack.Encoder().encode( [ (b":status", b"200"), (b"content-type", b"plain/text"), ] ), flags=["END_HEADERS"], ).serialize(), hyperframe.frame.DataFrame( stream_id=1, data=b"Hello, world!", flags=["END_STREAM"] ).serialize(), ] ) > async with AsyncHTTP2Connection( origin=origin, stream=stream, keepalive_expiry=5.0 ) as conn: tests/_async/test_http2.py:35: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , args = () kwargs = {'keepalive_expiry': 5.0, 'origin': , 'stream': } def __init__(self, *args, **kwargs) -> None: # type: ignore > raise RuntimeError( "Attempted to use http2 support, but the `h2` package is not " "installed. Use 'pip install httpcore[http2]'." ) E RuntimeError: Attempted to use http2 support, but the `h2` package is not installed. Use 'pip install httpcore[http2]'. httpcore/_async/__init__.py:13: RuntimeError _________________________ test_http2_connection[trio] __________________________ @pytest.mark.anyio async def test_http2_connection(): origin = Origin(b"https", b"example.com", 443) stream = AsyncMockStream( [ hyperframe.frame.SettingsFrame().serialize(), hyperframe.frame.HeadersFrame( stream_id=1, data=hpack.Encoder().encode( [ (b":status", b"200"), (b"content-type", b"plain/text"), ] ), flags=["END_HEADERS"], ).serialize(), hyperframe.frame.DataFrame( stream_id=1, data=b"Hello, world!", flags=["END_STREAM"] ).serialize(), ] ) > async with AsyncHTTP2Connection( origin=origin, stream=stream, keepalive_expiry=5.0 ) as conn: tests/_async/test_http2.py:35: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , args = () kwargs = {'keepalive_expiry': 5.0, 'origin': , 'stream': } def __init__(self, *args, **kwargs) -> None: # type: ignore > raise RuntimeError( "Attempted to use http2 support, but the `h2` package is not " "installed. Use 'pip install httpcore[http2]'." ) E RuntimeError: Attempted to use http2 support, but the `h2` package is not installed. Use 'pip install httpcore[http2]'. httpcore/_async/__init__.py:13: RuntimeError _________________ test_http2_connection_post_request[asyncio] __________________ @pytest.mark.anyio async def test_http2_connection_post_request(): origin = Origin(b"https", b"example.com", 443) stream = AsyncMockStream( [ hyperframe.frame.SettingsFrame().serialize(), hyperframe.frame.HeadersFrame( stream_id=1, data=hpack.Encoder().encode( [ (b":status", b"200"), (b"content-type", b"plain/text"), ] ), flags=["END_HEADERS"], ).serialize(), hyperframe.frame.DataFrame( stream_id=1, data=b"Hello, world!", flags=["END_STREAM"] ).serialize(), ] ) > async with AsyncHTTP2Connection(origin=origin, stream=stream) as conn: tests/_async/test_http2.py:76: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , args = () kwargs = {'origin': , 'stream': } def __init__(self, *args, **kwargs) -> None: # type: ignore > raise RuntimeError( "Attempted to use http2 support, but the `h2` package is not " "installed. Use 'pip install httpcore[http2]'." ) E RuntimeError: Attempted to use http2 support, but the `h2` package is not installed. Use 'pip install httpcore[http2]'. httpcore/_async/__init__.py:13: RuntimeError ___________________ test_http2_connection_post_request[trio] ___________________ @pytest.mark.anyio async def test_http2_connection_post_request(): origin = Origin(b"https", b"example.com", 443) stream = AsyncMockStream( [ hyperframe.frame.SettingsFrame().serialize(), hyperframe.frame.HeadersFrame( stream_id=1, data=hpack.Encoder().encode( [ (b":status", b"200"), (b"content-type", b"plain/text"), ] ), flags=["END_HEADERS"], ).serialize(), hyperframe.frame.DataFrame( stream_id=1, data=b"Hello, world!", flags=["END_STREAM"] ).serialize(), ] ) > async with AsyncHTTP2Connection(origin=origin, stream=stream) as conn: tests/_async/test_http2.py:76: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , args = () kwargs = {'origin': , 'stream': } def __init__(self, *args, **kwargs) -> None: # type: ignore > raise RuntimeError( "Attempted to use http2 support, but the `h2` package is not " "installed. Use 'pip install httpcore[http2]'." ) E RuntimeError: Attempted to use http2 support, but the `h2` package is not installed. Use 'pip install httpcore[http2]'. httpcore/_async/__init__.py:13: RuntimeError __________ test_http2_connection_with_remote_protocol_error[asyncio] ___________ @pytest.mark.anyio async def test_http2_connection_with_remote_protocol_error(): """ If a remote protocol error occurs, then no response will be returned, and the connection will not be reusable. """ origin = Origin(b"https", b"example.com", 443) stream = AsyncMockStream([b"Wait, this isn't valid HTTP!", b""]) > async with AsyncHTTP2Connection(origin=origin, stream=stream) as conn: tests/_async/test_http2.py:95: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , args = () kwargs = {'origin': , 'stream': } def __init__(self, *args, **kwargs) -> None: # type: ignore > raise RuntimeError( "Attempted to use http2 support, but the `h2` package is not " "installed. Use 'pip install httpcore[http2]'." ) E RuntimeError: Attempted to use http2 support, but the `h2` package is not installed. Use 'pip install httpcore[http2]'. httpcore/_async/__init__.py:13: RuntimeError ____________ test_http2_connection_with_remote_protocol_error[trio] ____________ @pytest.mark.anyio async def test_http2_connection_with_remote_protocol_error(): """ If a remote protocol error occurs, then no response will be returned, and the connection will not be reusable. """ origin = Origin(b"https", b"example.com", 443) stream = AsyncMockStream([b"Wait, this isn't valid HTTP!", b""]) > async with AsyncHTTP2Connection(origin=origin, stream=stream) as conn: tests/_async/test_http2.py:95: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , args = () kwargs = {'origin': , 'stream': } def __init__(self, *args, **kwargs) -> None: # type: ignore > raise RuntimeError( "Attempted to use http2 support, but the `h2` package is not " "installed. Use 'pip install httpcore[http2]'." ) E RuntimeError: Attempted to use http2 support, but the `h2` package is not installed. Use 'pip install httpcore[http2]'. httpcore/_async/__init__.py:13: RuntimeError _____________ test_http2_connection_with_stream_cancelled[asyncio] _____________ @pytest.mark.anyio async def test_http2_connection_with_stream_cancelled(): """ If a remote protocol error occurs, then no response will be returned, and the connection will not be reusable. """ origin = Origin(b"https", b"example.com", 443) stream = AsyncMockStream( [ hyperframe.frame.SettingsFrame().serialize(), hyperframe.frame.HeadersFrame( stream_id=1, data=hpack.Encoder().encode( [ (b":status", b"200"), (b"content-type", b"plain/text"), ] ), flags=["END_HEADERS"], ).serialize(), hyperframe.frame.RstStreamFrame(stream_id=1, error_code=8).serialize(), b"", ] ) > async with AsyncHTTP2Connection(origin=origin, stream=stream) as conn: tests/_async/test_http2.py:124: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , args = () kwargs = {'origin': , 'stream': } def __init__(self, *args, **kwargs) -> None: # type: ignore > raise RuntimeError( "Attempted to use http2 support, but the `h2` package is not " "installed. Use 'pip install httpcore[http2]'." ) E RuntimeError: Attempted to use http2 support, but the `h2` package is not installed. Use 'pip install httpcore[http2]'. httpcore/_async/__init__.py:13: RuntimeError ______________ test_http2_connection_with_stream_cancelled[trio] _______________ @pytest.mark.anyio async def test_http2_connection_with_stream_cancelled(): """ If a remote protocol error occurs, then no response will be returned, and the connection will not be reusable. """ origin = Origin(b"https", b"example.com", 443) stream = AsyncMockStream( [ hyperframe.frame.SettingsFrame().serialize(), hyperframe.frame.HeadersFrame( stream_id=1, data=hpack.Encoder().encode( [ (b":status", b"200"), (b"content-type", b"plain/text"), ] ), flags=["END_HEADERS"], ).serialize(), hyperframe.frame.RstStreamFrame(stream_id=1, error_code=8).serialize(), b"", ] ) > async with AsyncHTTP2Connection(origin=origin, stream=stream) as conn: tests/_async/test_http2.py:124: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , args = () kwargs = {'origin': , 'stream': } def __init__(self, *args, **kwargs) -> None: # type: ignore > raise RuntimeError( "Attempted to use http2 support, but the `h2` package is not " "installed. Use 'pip install httpcore[http2]'." ) E RuntimeError: Attempted to use http2 support, but the `h2` package is not installed. Use 'pip install httpcore[http2]'. httpcore/_async/__init__.py:13: RuntimeError _______________ test_http2_connection_with_flow_control[asyncio] _______________ @pytest.mark.anyio async def test_http2_connection_with_flow_control(): origin = Origin(b"https", b"example.com", 443) stream = AsyncMockStream( [ hyperframe.frame.SettingsFrame().serialize(), # Available flow: 65,535 hyperframe.frame.WindowUpdateFrame( stream_id=0, window_increment=10_000 ).serialize(), hyperframe.frame.WindowUpdateFrame( stream_id=1, window_increment=10_000 ).serialize(), # Available flow: 75,535 hyperframe.frame.WindowUpdateFrame( stream_id=0, window_increment=10_000 ).serialize(), hyperframe.frame.WindowUpdateFrame( stream_id=1, window_increment=10_000 ).serialize(), # Available flow: 85,535 hyperframe.frame.WindowUpdateFrame( stream_id=0, window_increment=10_000 ).serialize(), hyperframe.frame.WindowUpdateFrame( stream_id=1, window_increment=10_000 ).serialize(), # Available flow: 95,535 hyperframe.frame.WindowUpdateFrame( stream_id=0, window_increment=10_000 ).serialize(), hyperframe.frame.WindowUpdateFrame( stream_id=1, window_increment=10_000 ).serialize(), # Available flow: 105,535 hyperframe.frame.HeadersFrame( stream_id=1, data=hpack.Encoder().encode( [ (b":status", b"200"), (b"content-type", b"plain/text"), ] ), flags=["END_HEADERS"], ).serialize(), hyperframe.frame.DataFrame( stream_id=1, data=b"100,000 bytes received", flags=["END_STREAM"] ).serialize(), ] ) > async with AsyncHTTP2Connection(origin=origin, stream=stream) as conn: tests/_async/test_http2.py:179: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , args = () kwargs = {'origin': , 'stream': } def __init__(self, *args, **kwargs) -> None: # type: ignore > raise RuntimeError( "Attempted to use http2 support, but the `h2` package is not " "installed. Use 'pip install httpcore[http2]'." ) E RuntimeError: Attempted to use http2 support, but the `h2` package is not installed. Use 'pip install httpcore[http2]'. httpcore/_async/__init__.py:13: RuntimeError ________________ test_http2_connection_with_flow_control[trio] _________________ @pytest.mark.anyio async def test_http2_connection_with_flow_control(): origin = Origin(b"https", b"example.com", 443) stream = AsyncMockStream( [ hyperframe.frame.SettingsFrame().serialize(), # Available flow: 65,535 hyperframe.frame.WindowUpdateFrame( stream_id=0, window_increment=10_000 ).serialize(), hyperframe.frame.WindowUpdateFrame( stream_id=1, window_increment=10_000 ).serialize(), # Available flow: 75,535 hyperframe.frame.WindowUpdateFrame( stream_id=0, window_increment=10_000 ).serialize(), hyperframe.frame.WindowUpdateFrame( stream_id=1, window_increment=10_000 ).serialize(), # Available flow: 85,535 hyperframe.frame.WindowUpdateFrame( stream_id=0, window_increment=10_000 ).serialize(), hyperframe.frame.WindowUpdateFrame( stream_id=1, window_increment=10_000 ).serialize(), # Available flow: 95,535 hyperframe.frame.WindowUpdateFrame( stream_id=0, window_increment=10_000 ).serialize(), hyperframe.frame.WindowUpdateFrame( stream_id=1, window_increment=10_000 ).serialize(), # Available flow: 105,535 hyperframe.frame.HeadersFrame( stream_id=1, data=hpack.Encoder().encode( [ (b":status", b"200"), (b"content-type", b"plain/text"), ] ), flags=["END_HEADERS"], ).serialize(), hyperframe.frame.DataFrame( stream_id=1, data=b"100,000 bytes received", flags=["END_STREAM"] ).serialize(), ] ) > async with AsyncHTTP2Connection(origin=origin, stream=stream) as conn: tests/_async/test_http2.py:179: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , args = () kwargs = {'origin': , 'stream': } def __init__(self, *args, **kwargs) -> None: # type: ignore > raise RuntimeError( "Attempted to use http2 support, but the `h2` package is not " "installed. Use 'pip install httpcore[http2]'." ) E RuntimeError: Attempted to use http2 support, but the `h2` package is not installed. Use 'pip install httpcore[http2]'. httpcore/_async/__init__.py:13: RuntimeError _________________ test_http2_connection_attempt_close[asyncio] _________________ @pytest.mark.anyio async def test_http2_connection_attempt_close(): """ A connection can only be closed when it is idle. """ origin = Origin(b"https", b"example.com", 443) stream = AsyncMockStream( [ hyperframe.frame.SettingsFrame().serialize(), hyperframe.frame.HeadersFrame( stream_id=1, data=hpack.Encoder().encode( [ (b":status", b"200"), (b"content-type", b"plain/text"), ] ), flags=["END_HEADERS"], ).serialize(), hyperframe.frame.DataFrame( stream_id=1, data=b"Hello, world!", flags=["END_STREAM"] ).serialize(), ] ) > async with AsyncHTTP2Connection(origin=origin, stream=stream) as conn: tests/_async/test_http2.py:213: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , args = () kwargs = {'origin': , 'stream': } def __init__(self, *args, **kwargs) -> None: # type: ignore > raise RuntimeError( "Attempted to use http2 support, but the `h2` package is not " "installed. Use 'pip install httpcore[http2]'." ) E RuntimeError: Attempted to use http2 support, but the `h2` package is not installed. Use 'pip install httpcore[http2]'. httpcore/_async/__init__.py:13: RuntimeError __________________ test_http2_connection_attempt_close[trio] ___________________ @pytest.mark.anyio async def test_http2_connection_attempt_close(): """ A connection can only be closed when it is idle. """ origin = Origin(b"https", b"example.com", 443) stream = AsyncMockStream( [ hyperframe.frame.SettingsFrame().serialize(), hyperframe.frame.HeadersFrame( stream_id=1, data=hpack.Encoder().encode( [ (b":status", b"200"), (b"content-type", b"plain/text"), ] ), flags=["END_HEADERS"], ).serialize(), hyperframe.frame.DataFrame( stream_id=1, data=b"Hello, world!", flags=["END_STREAM"] ).serialize(), ] ) > async with AsyncHTTP2Connection(origin=origin, stream=stream) as conn: tests/_async/test_http2.py:213: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , args = () kwargs = {'origin': , 'stream': } def __init__(self, *args, **kwargs) -> None: # type: ignore > raise RuntimeError( "Attempted to use http2 support, but the `h2` package is not " "installed. Use 'pip install httpcore[http2]'." ) E RuntimeError: Attempted to use http2 support, but the `h2` package is not installed. Use 'pip install httpcore[http2]'. httpcore/_async/__init__.py:13: RuntimeError _______________ test_http2_request_to_incorrect_origin[asyncio] ________________ @pytest.mark.anyio async def test_http2_request_to_incorrect_origin(): """ A connection can only send requests to whichever origin it is connected to. """ origin = Origin(b"https", b"example.com", 443) stream = AsyncMockStream([]) > async with AsyncHTTP2Connection(origin=origin, stream=stream) as conn: tests/_async/test_http2.py:231: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , args = () kwargs = {'origin': , 'stream': } def __init__(self, *args, **kwargs) -> None: # type: ignore > raise RuntimeError( "Attempted to use http2 support, but the `h2` package is not " "installed. Use 'pip install httpcore[http2]'." ) E RuntimeError: Attempted to use http2 support, but the `h2` package is not installed. Use 'pip install httpcore[http2]'. httpcore/_async/__init__.py:13: RuntimeError _________________ test_http2_request_to_incorrect_origin[trio] _________________ @pytest.mark.anyio async def test_http2_request_to_incorrect_origin(): """ A connection can only send requests to whichever origin it is connected to. """ origin = Origin(b"https", b"example.com", 443) stream = AsyncMockStream([]) > async with AsyncHTTP2Connection(origin=origin, stream=stream) as conn: tests/_async/test_http2.py:231: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , args = () kwargs = {'origin': , 'stream': } def __init__(self, *args, **kwargs) -> None: # type: ignore > raise RuntimeError( "Attempted to use http2 support, but the `h2` package is not " "installed. Use 'pip install httpcore[http2]'." ) E RuntimeError: Attempted to use http2 support, but the `h2` package is not installed. Use 'pip install httpcore[http2]'. httpcore/_async/__init__.py:13: RuntimeError ____________________________ test_http2_connection _____________________________ def test_http2_connection(): origin = Origin(b"https", b"example.com", 443) network_backend = MockBackend( [ hyperframe.frame.SettingsFrame().serialize(), hyperframe.frame.HeadersFrame( stream_id=1, data=hpack.Encoder().encode( [ (b":status", b"200"), (b"content-type", b"plain/text"), ] ), flags=["END_HEADERS"], ).serialize(), hyperframe.frame.DataFrame( stream_id=1, data=b"Hello, world!", flags=["END_STREAM"] ).serialize(), ], http2=True, ) with HTTPConnection( origin=origin, network_backend=network_backend, http2=True ) as conn: > response = conn.request("GET", "https://example.com/") tests/_sync/test_connection.py:103: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ httpcore/_sync/interfaces.py:41: in request response = self.handle_request(request) httpcore/_sync/connection.py:90: in handle_request raise exc httpcore/_sync/connection.py:75: in handle_request from .http2 import HTTP2Connection _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ import enum import time import types import typing > import h2.config E ModuleNotFoundError: No module named 'h2' httpcore/_sync/http2.py:6: ModuleNotFoundError ____________________________ test_http2_connection _____________________________ def test_http2_connection(): origin = Origin(b"https", b"example.com", 443) stream = MockStream( [ hyperframe.frame.SettingsFrame().serialize(), hyperframe.frame.HeadersFrame( stream_id=1, data=hpack.Encoder().encode( [ (b":status", b"200"), (b"content-type", b"plain/text"), ] ), flags=["END_HEADERS"], ).serialize(), hyperframe.frame.DataFrame( stream_id=1, data=b"Hello, world!", flags=["END_STREAM"] ).serialize(), ] ) > with HTTP2Connection( origin=origin, stream=stream, keepalive_expiry=5.0 ) as conn: tests/_sync/test_http2.py:35: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , args = () kwargs = {'keepalive_expiry': 5.0, 'origin': , 'stream': } def __init__(self, *args, **kwargs) -> None: # type: ignore > raise RuntimeError( "Attempted to use http2 support, but the `h2` package is not " "installed. Use 'pip install httpcore[http2]'." ) E RuntimeError: Attempted to use http2 support, but the `h2` package is not installed. Use 'pip install httpcore[http2]'. httpcore/_sync/__init__.py:13: RuntimeError ______________________ test_http2_connection_post_request ______________________ def test_http2_connection_post_request(): origin = Origin(b"https", b"example.com", 443) stream = MockStream( [ hyperframe.frame.SettingsFrame().serialize(), hyperframe.frame.HeadersFrame( stream_id=1, data=hpack.Encoder().encode( [ (b":status", b"200"), (b"content-type", b"plain/text"), ] ), flags=["END_HEADERS"], ).serialize(), hyperframe.frame.DataFrame( stream_id=1, data=b"Hello, world!", flags=["END_STREAM"] ).serialize(), ] ) > with HTTP2Connection(origin=origin, stream=stream) as conn: tests/_sync/test_http2.py:76: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , args = () kwargs = {'origin': , 'stream': } def __init__(self, *args, **kwargs) -> None: # type: ignore > raise RuntimeError( "Attempted to use http2 support, but the `h2` package is not " "installed. Use 'pip install httpcore[http2]'." ) E RuntimeError: Attempted to use http2 support, but the `h2` package is not installed. Use 'pip install httpcore[http2]'. httpcore/_sync/__init__.py:13: RuntimeError _______________ test_http2_connection_with_remote_protocol_error _______________ def test_http2_connection_with_remote_protocol_error(): """ If a remote protocol error occurs, then no response will be returned, and the connection will not be reusable. """ origin = Origin(b"https", b"example.com", 443) stream = MockStream([b"Wait, this isn't valid HTTP!", b""]) > with HTTP2Connection(origin=origin, stream=stream) as conn: tests/_sync/test_http2.py:95: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , args = () kwargs = {'origin': , 'stream': } def __init__(self, *args, **kwargs) -> None: # type: ignore > raise RuntimeError( "Attempted to use http2 support, but the `h2` package is not " "installed. Use 'pip install httpcore[http2]'." ) E RuntimeError: Attempted to use http2 support, but the `h2` package is not installed. Use 'pip install httpcore[http2]'. httpcore/_sync/__init__.py:13: RuntimeError _________________ test_http2_connection_with_stream_cancelled __________________ def test_http2_connection_with_stream_cancelled(): """ If a remote protocol error occurs, then no response will be returned, and the connection will not be reusable. """ origin = Origin(b"https", b"example.com", 443) stream = MockStream( [ hyperframe.frame.SettingsFrame().serialize(), hyperframe.frame.HeadersFrame( stream_id=1, data=hpack.Encoder().encode( [ (b":status", b"200"), (b"content-type", b"plain/text"), ] ), flags=["END_HEADERS"], ).serialize(), hyperframe.frame.RstStreamFrame(stream_id=1, error_code=8).serialize(), b"", ] ) > with HTTP2Connection(origin=origin, stream=stream) as conn: tests/_sync/test_http2.py:124: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , args = () kwargs = {'origin': , 'stream': } def __init__(self, *args, **kwargs) -> None: # type: ignore > raise RuntimeError( "Attempted to use http2 support, but the `h2` package is not " "installed. Use 'pip install httpcore[http2]'." ) E RuntimeError: Attempted to use http2 support, but the `h2` package is not installed. Use 'pip install httpcore[http2]'. httpcore/_sync/__init__.py:13: RuntimeError ___________________ test_http2_connection_with_flow_control ____________________ def test_http2_connection_with_flow_control(): origin = Origin(b"https", b"example.com", 443) stream = MockStream( [ hyperframe.frame.SettingsFrame().serialize(), # Available flow: 65,535 hyperframe.frame.WindowUpdateFrame( stream_id=0, window_increment=10_000 ).serialize(), hyperframe.frame.WindowUpdateFrame( stream_id=1, window_increment=10_000 ).serialize(), # Available flow: 75,535 hyperframe.frame.WindowUpdateFrame( stream_id=0, window_increment=10_000 ).serialize(), hyperframe.frame.WindowUpdateFrame( stream_id=1, window_increment=10_000 ).serialize(), # Available flow: 85,535 hyperframe.frame.WindowUpdateFrame( stream_id=0, window_increment=10_000 ).serialize(), hyperframe.frame.WindowUpdateFrame( stream_id=1, window_increment=10_000 ).serialize(), # Available flow: 95,535 hyperframe.frame.WindowUpdateFrame( stream_id=0, window_increment=10_000 ).serialize(), hyperframe.frame.WindowUpdateFrame( stream_id=1, window_increment=10_000 ).serialize(), # Available flow: 105,535 hyperframe.frame.HeadersFrame( stream_id=1, data=hpack.Encoder().encode( [ (b":status", b"200"), (b"content-type", b"plain/text"), ] ), flags=["END_HEADERS"], ).serialize(), hyperframe.frame.DataFrame( stream_id=1, data=b"100,000 bytes received", flags=["END_STREAM"] ).serialize(), ] ) > with HTTP2Connection(origin=origin, stream=stream) as conn: tests/_sync/test_http2.py:179: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , args = () kwargs = {'origin': , 'stream': } def __init__(self, *args, **kwargs) -> None: # type: ignore > raise RuntimeError( "Attempted to use http2 support, but the `h2` package is not " "installed. Use 'pip install httpcore[http2]'." ) E RuntimeError: Attempted to use http2 support, but the `h2` package is not installed. Use 'pip install httpcore[http2]'. httpcore/_sync/__init__.py:13: RuntimeError _____________________ test_http2_connection_attempt_close ______________________ def test_http2_connection_attempt_close(): """ A connection can only be closed when it is idle. """ origin = Origin(b"https", b"example.com", 443) stream = MockStream( [ hyperframe.frame.SettingsFrame().serialize(), hyperframe.frame.HeadersFrame( stream_id=1, data=hpack.Encoder().encode( [ (b":status", b"200"), (b"content-type", b"plain/text"), ] ), flags=["END_HEADERS"], ).serialize(), hyperframe.frame.DataFrame( stream_id=1, data=b"Hello, world!", flags=["END_STREAM"] ).serialize(), ] ) > with HTTP2Connection(origin=origin, stream=stream) as conn: tests/_sync/test_http2.py:213: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , args = () kwargs = {'origin': , 'stream': } def __init__(self, *args, **kwargs) -> None: # type: ignore > raise RuntimeError( "Attempted to use http2 support, but the `h2` package is not " "installed. Use 'pip install httpcore[http2]'." ) E RuntimeError: Attempted to use http2 support, but the `h2` package is not installed. Use 'pip install httpcore[http2]'. httpcore/_sync/__init__.py:13: RuntimeError ____________________ test_http2_request_to_incorrect_origin ____________________ def test_http2_request_to_incorrect_origin(): """ A connection can only send requests to whichever origin it is connected to. """ origin = Origin(b"https", b"example.com", 443) stream = MockStream([]) > with HTTP2Connection(origin=origin, stream=stream) as conn: tests/_sync/test_http2.py:231: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , args = () kwargs = {'origin': , 'stream': } def __init__(self, *args, **kwargs) -> None: # type: ignore > raise RuntimeError( "Attempted to use http2 support, but the `h2` package is not " "installed. Use 'pip install httpcore[http2]'." ) E RuntimeError: Attempted to use http2 support, but the `h2` package is not installed. Use 'pip install httpcore[http2]'. httpcore/_sync/__init__.py:13: RuntimeError =============================== warnings summary =============================== tests/_async/test_integration.py::test_ssl_request[asyncio] tests/_async/test_integration.py::test_ssl_request[trio] tests/_async/test_integration.py::test_extra_info[asyncio] tests/_async/test_integration.py::test_extra_info[trio] tests/_sync/test_integration.py::test_ssl_request tests/_sync/test_integration.py::test_extra_info /usr/lib/python3.10/site-packages/pytest_httpbin/serve.py:65: DeprecationWarning: ssl.wrap_socket() is deprecated, use SSLContext.wrap_socket() ssock = ssl.wrap_socket( tests/_async/test_integration.py::test_ssl_request[asyncio] tests/_async/test_integration.py::test_ssl_request[trio] tests/_async/test_integration.py::test_extra_info[asyncio] tests/_async/test_integration.py::test_extra_info[trio] tests/_sync/test_integration.py::test_ssl_request tests/_sync/test_integration.py::test_extra_info /usr/lib/python3.10/ssl.py:1433: DeprecationWarning: ssl.PROTOCOL_TLS is deprecated context = SSLContext(ssl_version) tests/_sync/test_connection_pool.py::test_connection_pool_concurrency_same_domain_closing /usr/lib/python3.10/site-packages/_pytest/threadexception.py:75: PytestUnhandledThreadExceptionWarning: Exception in thread Thread-10 (fetch) Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/h11/_state.py", line 249, in _fire_event_triggered_transitions new_state = EVENT_TRIGGERED_TRANSITIONS[role][state][event_type] KeyError: During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/build/python-httpcore/src/httpcore-0.14.3/httpcore/_exceptions.py", line 8, in map_exceptions yield File "/build/python-httpcore/src/httpcore-0.14.3/httpcore/_sync/http11.py", line 169, in _receive_event event = self._h11_state.next_event() File "/usr/lib/python3.10/site-packages/h11/_connection.py", line 443, in next_event exc._reraise_as_remote_protocol_error() File "/usr/lib/python3.10/site-packages/h11/_util.py", line 76, in _reraise_as_remote_protocol_error raise self File "/usr/lib/python3.10/site-packages/h11/_connection.py", line 427, in next_event self._process_event(self.their_role, event) File "/usr/lib/python3.10/site-packages/h11/_connection.py", line 242, in _process_event self._cstate.process_event(role, type(event), server_switch_event) File "/usr/lib/python3.10/site-packages/h11/_state.py", line 238, in process_event self._fire_event_triggered_transitions(role, event_type) File "/usr/lib/python3.10/site-packages/h11/_state.py", line 251, in _fire_event_triggered_transitions raise LocalProtocolError( h11._util.RemoteProtocolError: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3.10/threading.py", line 1009, in _bootstrap_inner self.run() File "/usr/lib/python3.10/threading.py", line 946, in run self._target(*self._args, **self._kwargs) File "/build/python-httpcore/src/httpcore-0.14.3/tests/_sync/test_connection_pool.py", line 358, in fetch with pool.stream("GET", f"https://{domain}/") as response: File "/usr/lib/python3.10/contextlib.py", line 135, in __enter__ return next(self.gen) File "/build/python-httpcore/src/httpcore-0.14.3/httpcore/_sync/interfaces.py", line 73, in stream response = self.handle_request(request) File "/build/python-httpcore/src/httpcore-0.14.3/httpcore/_sync/connection_pool.py", line 248, in handle_request raise exc File "/build/python-httpcore/src/httpcore-0.14.3/httpcore/_sync/connection_pool.py", line 232, in handle_request response = connection.handle_request(request) File "/build/python-httpcore/src/httpcore-0.14.3/httpcore/_sync/connection.py", line 94, in handle_request return self._connection.handle_request(request) File "/build/python-httpcore/src/httpcore-0.14.3/httpcore/_sync/http11.py", line 102, in handle_request raise exc File "/build/python-httpcore/src/httpcore-0.14.3/httpcore/_sync/http11.py", line 81, in handle_request ) = self._receive_response_headers(**kwargs) File "/build/python-httpcore/src/httpcore-0.14.3/httpcore/_sync/http11.py", line 143, in _receive_response_headers event = self._receive_event(timeout=timeout) File "/build/python-httpcore/src/httpcore-0.14.3/httpcore/_sync/http11.py", line 168, in _receive_event with map_exceptions({h11.RemoteProtocolError: RemoteProtocolError}): File "/usr/lib/python3.10/contextlib.py", line 153, in __exit__ self.gen.throw(typ, value, traceback) File "/build/python-httpcore/src/httpcore-0.14.3/httpcore/_exceptions.py", line 12, in map_exceptions raise to_exc(exc) httpcore.RemoteProtocolError: can't handle event type ConnectionClosed when role=SERVER and state=SEND_RESPONSE warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg)) -- Docs: https://docs.pytest.org/en/stable/warnings.html =========================== short test summary info ============================ FAILED tests/_async/test_connection.py::test_http2_connection[asyncio] - Modu... FAILED tests/_async/test_connection.py::test_http2_connection[trio] - ModuleN... FAILED tests/_async/test_http2.py::test_http2_connection[asyncio] - RuntimeEr... FAILED tests/_async/test_http2.py::test_http2_connection[trio] - RuntimeError... FAILED tests/_async/test_http2.py::test_http2_connection_post_request[asyncio] FAILED tests/_async/test_http2.py::test_http2_connection_post_request[trio] FAILED tests/_async/test_http2.py::test_http2_connection_with_remote_protocol_error[asyncio] FAILED tests/_async/test_http2.py::test_http2_connection_with_remote_protocol_error[trio] FAILED tests/_async/test_http2.py::test_http2_connection_with_stream_cancelled[asyncio] FAILED tests/_async/test_http2.py::test_http2_connection_with_stream_cancelled[trio] FAILED tests/_async/test_http2.py::test_http2_connection_with_flow_control[asyncio] FAILED tests/_async/test_http2.py::test_http2_connection_with_flow_control[trio] FAILED tests/_async/test_http2.py::test_http2_connection_attempt_close[asyncio] FAILED tests/_async/test_http2.py::test_http2_connection_attempt_close[trio] FAILED tests/_async/test_http2.py::test_http2_request_to_incorrect_origin[asyncio] FAILED tests/_async/test_http2.py::test_http2_request_to_incorrect_origin[trio] FAILED tests/_sync/test_connection.py::test_http2_connection - ModuleNotFound... FAILED tests/_sync/test_http2.py::test_http2_connection - RuntimeError: Attem... FAILED tests/_sync/test_http2.py::test_http2_connection_post_request - Runtim... FAILED tests/_sync/test_http2.py::test_http2_connection_with_remote_protocol_error FAILED tests/_sync/test_http2.py::test_http2_connection_with_stream_cancelled FAILED tests/_sync/test_http2.py::test_http2_connection_with_flow_control - R... FAILED tests/_sync/test_http2.py::test_http2_connection_attempt_close - Runti... FAILED tests/_sync/test_http2.py::test_http2_request_to_incorrect_origin - Ru... ================= 24 failed, 100 passed, 13 warnings in 7.88s ================== ==> ERROR: A failure occurred in check().  Aborting...