Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
karpetrosyan committed May 30, 2023
1 parent 65e18a8 commit 5a77d48
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 104 deletions.
128 changes: 76 additions & 52 deletions tests/_async/test_connection_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,58 +185,82 @@ async def test_debug_request(caplog):
async with AsyncConnectionPool(network_backend=network_backend) as pool:
await pool.request("GET", "http://example.com/")

assert caplog.record_tuples == [('httpcore.connection_pool',
10,
"create_connection.started origin='http://example.com:80'"),
('httpcore.connection_pool',
10,
'create_connection.complete return_value=<AsyncHTTPConnection [CONNECTING]>'),
('httpcore.connection_pool',
10,
'set_connection.started connection=<AsyncHTTPConnection [CONNECTING]>'),
('httpcore.connection_pool', 10, 'set_connection.complete'),
('httpcore.connection_pool', 10, 'Waiting for a connection.'),
('httpcore.connection_pool',
10,
'The ConnectionPool currently has 1 request(s) awaiting connections.'),
('httpcore.connection_pool', 10, 'Connection received.'),
('httpcore.connection_pool',
10,
'The ConnectionPool currently has 0 request(s) awaiting connections.'),
('httpcore.connection',
10,
"connect_tcp.started host='example.com' port=80 local_address=None "
'timeout=None socket_options=None'),
('httpcore.connection',
10,
'connect_tcp.complete return_value=<httpcore.AsyncMockStream>'),
('httpcore.http11',
10,
"send_request_headers.started request=<Request [b'GET']>"),
('httpcore.http11', 10, 'send_request_headers.complete'),
('httpcore.http11',
10,
"send_request_body.started request=<Request [b'GET']>"),
('httpcore.http11', 10, 'send_request_body.complete'),
('httpcore.http11',
10,
"receive_response_headers.started request=<Request [b'GET']>"),
('httpcore.http11',
10,
"receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', "
"[(b'Content-Type', b'plain/text'), (b'Content-Length', b'13')])"),
('httpcore.http11',
10,
"receive_response_body.started request=<Request [b'GET']>"),
('httpcore.http11', 10, 'receive_response_body.complete'),
('httpcore.http11', 10, 'response_closed.started'),
('httpcore.http11', 10, 'response_closed.complete'),
('httpcore.connection_pool',
10,
"Connection: <AsyncHTTPConnection ['http://example.com:80', HTTP/1.1, IDLE, "
'Request Count: 1]> was returned into the pool'),
('httpcore.connection', 10, 'close.started'),
('httpcore.connection', 10, 'close.complete')]
assert caplog.record_tuples == [
(
"httpcore.connection_pool",
10,
"create_connection.started origin='http://example.com:80'",
),
(
"httpcore.connection_pool",
10,
"create_connection.complete return_value=<AsyncHTTPConnection [CONNECTING]>",
),
(
"httpcore.connection_pool",
10,
"set_connection.started connection=<AsyncHTTPConnection [CONNECTING]>",
),
("httpcore.connection_pool", 10, "set_connection.complete"),
("httpcore.connection_pool", 10, "Waiting for a connection."),
(
"httpcore.connection_pool",
10,
"The ConnectionPool currently has 1 request(s) awaiting connections.",
),
("httpcore.connection_pool", 10, "Connection received."),
(
"httpcore.connection_pool",
10,
"The ConnectionPool currently has 0 request(s) awaiting connections.",
),
(
"httpcore.connection",
10,
"connect_tcp.started host='example.com' port=80 local_address=None "
"timeout=None socket_options=None",
),
(
"httpcore.connection",
10,
"connect_tcp.complete return_value=<httpcore.AsyncMockStream>",
),
(
"httpcore.http11",
10,
"send_request_headers.started request=<Request [b'GET']>",
),
("httpcore.http11", 10, "send_request_headers.complete"),
("httpcore.http11", 10, "send_request_body.started request=<Request [b'GET']>"),
("httpcore.http11", 10, "send_request_body.complete"),
(
"httpcore.http11",
10,
"receive_response_headers.started request=<Request [b'GET']>",
),
(
"httpcore.http11",
10,
"receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', "
"[(b'Content-Type', b'plain/text'), (b'Content-Length', b'13')])",
),
(
"httpcore.http11",
10,
"receive_response_body.started request=<Request [b'GET']>",
),
("httpcore.http11", 10, "receive_response_body.complete"),
("httpcore.http11", 10, "response_closed.started"),
("httpcore.http11", 10, "response_closed.complete"),
(
"httpcore.connection_pool",
10,
"Connection: <AsyncHTTPConnection ['http://example.com:80', HTTP/1.1, IDLE, "
"Request Count: 1]> was returned into the pool",
),
("httpcore.connection", 10, "close.started"),
("httpcore.connection", 10, "close.complete"),
]


@pytest.mark.anyio
Expand Down
128 changes: 76 additions & 52 deletions tests/_sync/test_connection_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,58 +185,82 @@ def test_debug_request(caplog):
with ConnectionPool(network_backend=network_backend) as pool:
pool.request("GET", "http://example.com/")

assert caplog.record_tuples == [('httpcore.connection_pool',
10,
"create_connection.started origin='http://example.com:80'"),
('httpcore.connection_pool',
10,
'create_connection.complete return_value=<HTTPConnection [CONNECTING]>'),
('httpcore.connection_pool',
10,
'set_connection.started connection=<HTTPConnection [CONNECTING]>'),
('httpcore.connection_pool', 10, 'set_connection.complete'),
('httpcore.connection_pool', 10, 'Waiting for a connection.'),
('httpcore.connection_pool',
10,
'The ConnectionPool currently has 1 request(s) awaiting connections.'),
('httpcore.connection_pool', 10, 'Connection received.'),
('httpcore.connection_pool',
10,
'The ConnectionPool currently has 0 request(s) awaiting connections.'),
('httpcore.connection',
10,
"connect_tcp.started host='example.com' port=80 local_address=None "
'timeout=None socket_options=None'),
('httpcore.connection',
10,
'connect_tcp.complete return_value=<httpcore.MockStream>'),
('httpcore.http11',
10,
"send_request_headers.started request=<Request [b'GET']>"),
('httpcore.http11', 10, 'send_request_headers.complete'),
('httpcore.http11',
10,
"send_request_body.started request=<Request [b'GET']>"),
('httpcore.http11', 10, 'send_request_body.complete'),
('httpcore.http11',
10,
"receive_response_headers.started request=<Request [b'GET']>"),
('httpcore.http11',
10,
"receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', "
"[(b'Content-Type', b'plain/text'), (b'Content-Length', b'13')])"),
('httpcore.http11',
10,
"receive_response_body.started request=<Request [b'GET']>"),
('httpcore.http11', 10, 'receive_response_body.complete'),
('httpcore.http11', 10, 'response_closed.started'),
('httpcore.http11', 10, 'response_closed.complete'),
('httpcore.connection_pool',
10,
"Connection: <HTTPConnection ['http://example.com:80', HTTP/1.1, IDLE, "
'Request Count: 1]> was returned into the pool'),
('httpcore.connection', 10, 'close.started'),
('httpcore.connection', 10, 'close.complete')]
assert caplog.record_tuples == [
(
"httpcore.connection_pool",
10,
"create_connection.started origin='http://example.com:80'",
),
(
"httpcore.connection_pool",
10,
"create_connection.complete return_value=<HTTPConnection [CONNECTING]>",
),
(
"httpcore.connection_pool",
10,
"set_connection.started connection=<HTTPConnection [CONNECTING]>",
),
("httpcore.connection_pool", 10, "set_connection.complete"),
("httpcore.connection_pool", 10, "Waiting for a connection."),
(
"httpcore.connection_pool",
10,
"The ConnectionPool currently has 1 request(s) awaiting connections.",
),
("httpcore.connection_pool", 10, "Connection received."),
(
"httpcore.connection_pool",
10,
"The ConnectionPool currently has 0 request(s) awaiting connections.",
),
(
"httpcore.connection",
10,
"connect_tcp.started host='example.com' port=80 local_address=None "
"timeout=None socket_options=None",
),
(
"httpcore.connection",
10,
"connect_tcp.complete return_value=<httpcore.MockStream>",
),
(
"httpcore.http11",
10,
"send_request_headers.started request=<Request [b'GET']>",
),
("httpcore.http11", 10, "send_request_headers.complete"),
("httpcore.http11", 10, "send_request_body.started request=<Request [b'GET']>"),
("httpcore.http11", 10, "send_request_body.complete"),
(
"httpcore.http11",
10,
"receive_response_headers.started request=<Request [b'GET']>",
),
(
"httpcore.http11",
10,
"receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', "
"[(b'Content-Type', b'plain/text'), (b'Content-Length', b'13')])",
),
(
"httpcore.http11",
10,
"receive_response_body.started request=<Request [b'GET']>",
),
("httpcore.http11", 10, "receive_response_body.complete"),
("httpcore.http11", 10, "response_closed.started"),
("httpcore.http11", 10, "response_closed.complete"),
(
"httpcore.connection_pool",
10,
"Connection: <HTTPConnection ['http://example.com:80', HTTP/1.1, IDLE, "
"Request Count: 1]> was returned into the pool",
),
("httpcore.connection", 10, "close.started"),
("httpcore.connection", 10, "close.complete"),
]



Expand Down

0 comments on commit 5a77d48

Please sign in to comment.