Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ repos:
hooks:
- id: yesqa
- repo: https://github.com/PyCQA/isort
rev: '5.13.2'
rev: '6.0.0'
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: '24.10.0'
rev: '25.1.0'
hooks:
- id: black
language_version: python3 # Should be a command that runs python
Expand Down Expand Up @@ -119,7 +119,7 @@ repos:
exclude: >-
^CHANGES\.rst$
- repo: https://github.com/codespell-project/codespell
rev: v2.4.0
rev: v2.4.1
hooks:
- id: codespell
additional_dependencies:
Expand Down
22 changes: 11 additions & 11 deletions tests/test_client_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,21 @@ def params() -> _Params:


async def test_close_coro(
create_session: Callable[..., Awaitable[ClientSession]]
create_session: Callable[..., Awaitable[ClientSession]],
) -> None:
session = await create_session()
await session.close()


async def test_init_headers_simple_dict(
create_session: Callable[..., Awaitable[ClientSession]]
create_session: Callable[..., Awaitable[ClientSession]],
) -> None:
session = await create_session(headers={"h1": "header1", "h2": "header2"})
assert sorted(session.headers.items()) == ([("h1", "header1"), ("h2", "header2")])


async def test_init_headers_list_of_tuples(
create_session: Callable[..., Awaitable[ClientSession]]
create_session: Callable[..., Awaitable[ClientSession]],
) -> None:
session = await create_session(
headers=[("h1", "header1"), ("h2", "header2"), ("h3", "header3")]
Expand All @@ -123,7 +123,7 @@ async def test_init_headers_list_of_tuples(


async def test_init_headers_MultiDict(
create_session: Callable[..., Awaitable[ClientSession]]
create_session: Callable[..., Awaitable[ClientSession]],
) -> None:
session = await create_session(
headers=MultiDict([("h1", "header1"), ("h2", "header2"), ("h3", "header3")])
Expand All @@ -134,7 +134,7 @@ async def test_init_headers_MultiDict(


async def test_init_headers_list_of_tuples_with_duplicates(
create_session: Callable[..., Awaitable[ClientSession]]
create_session: Callable[..., Awaitable[ClientSession]],
) -> None:
session = await create_session(
headers=[("h1", "header11"), ("h2", "header21"), ("h1", "header12")]
Expand All @@ -145,7 +145,7 @@ async def test_init_headers_list_of_tuples_with_duplicates(


async def test_init_cookies_with_simple_dict(
create_session: Callable[..., Awaitable[ClientSession]]
create_session: Callable[..., Awaitable[ClientSession]],
) -> None:
session = await create_session(cookies={"c1": "cookie1", "c2": "cookie2"})
cookies = session.cookie_jar.filter_cookies(URL())
Expand All @@ -155,7 +155,7 @@ async def test_init_cookies_with_simple_dict(


async def test_init_cookies_with_list_of_tuples(
create_session: Callable[..., Awaitable[ClientSession]]
create_session: Callable[..., Awaitable[ClientSession]],
) -> None:
session = await create_session(cookies=[("c1", "cookie1"), ("c2", "cookie2")])

Expand All @@ -166,7 +166,7 @@ async def test_init_cookies_with_list_of_tuples(


async def test_merge_headers(
create_session: Callable[..., Awaitable[ClientSession]]
create_session: Callable[..., Awaitable[ClientSession]],
) -> None:
# Check incoming simple dict
session = await create_session(headers={"h1": "header1", "h2": "header2"})
Expand All @@ -177,7 +177,7 @@ async def test_merge_headers(


async def test_merge_headers_with_multi_dict(
create_session: Callable[..., Awaitable[ClientSession]]
create_session: Callable[..., Awaitable[ClientSession]],
) -> None:
session = await create_session(headers={"h1": "header1", "h2": "header2"})
headers = session._prepare_headers(MultiDict([("h1", "h1")]))
Expand All @@ -186,7 +186,7 @@ async def test_merge_headers_with_multi_dict(


async def test_merge_headers_with_list_of_tuples(
create_session: Callable[..., Awaitable[ClientSession]]
create_session: Callable[..., Awaitable[ClientSession]],
) -> None:
session = await create_session(headers={"h1": "header1", "h2": "header2"})
headers = session._prepare_headers([("h1", "h1")])
Expand Down Expand Up @@ -1049,7 +1049,7 @@ async def test_client_session_timeout_default_args(


async def test_client_session_timeout_zero(
create_mocked_conn: Callable[[], ResponseHandler]
create_mocked_conn: Callable[[], ResponseHandler],
) -> None:
async def create_connection(
req: object, traces: object, timeout: object
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cookiejar.py
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ def test_pickle_format(cookies_to_send: SimpleCookie) -> None:
],
)
async def test_treat_as_secure_origin_init(
url: Union[str, URL, List[str], List[URL]]
url: Union[str, URL, List[str], List[URL]],
) -> None:
jar = CookieJar(unsafe=True, treat_as_secure_origin=url)
assert jar._treat_as_secure_origin == frozenset({URL("http://127.0.0.1")})
Expand Down
16 changes: 8 additions & 8 deletions tests/test_http_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ def test_bad_header_name(
(
"Content-Length: -5", # https://www.rfc-editor.org/rfc/rfc9110.html#name-content-length
"Content-Length: +256",
"Content-Length: \N{superscript one}",
"Content-Length: \N{mathematical double-struck digit one}",
"Content-Length: \N{SUPERSCRIPT ONE}",
"Content-Length: \N{MATHEMATICAL DOUBLE-STRUCK DIGIT ONE}",
"Foo: abc\rdef", # https://www.rfc-editor.org/rfc/rfc9110.html#section-5.5-5
"Bar: abc\ndef",
"Baz: abc\x00def",
Expand Down Expand Up @@ -820,11 +820,11 @@ def test_http_request_bad_status_line(parser: HttpRequestParser) -> None:
_num: Dict[bytes, str] = {
# dangerous: accepted by Python int()
# unicodedata.category("\U0001D7D9") == 'Nd'
"\N{mathematical double-struck digit one}".encode(): "utf8digit",
"\N{MATHEMATICAL DOUBLE-STRUCK DIGIT ONE}".encode(): "utf8digit",
# only added for interop tests, refused by Python int()
# unicodedata.category("\U000000B9") == 'No'
"\N{superscript one}".encode(): "utf8number",
"\N{superscript one}".encode("latin-1"): "latin1number",
"\N{SUPERSCRIPT ONE}".encode(): "utf8number",
"\N{SUPERSCRIPT ONE}".encode("latin-1"): "latin1number",
}


Expand All @@ -839,7 +839,7 @@ def test_http_request_bad_status_line_number(

def test_http_request_bad_status_line_separator(parser: HttpRequestParser) -> None:
# single code point, old, multibyte NFKC, multibyte NFKD
utf8sep = "\N{arabic ligature sallallahou alayhe wasallam}".encode()
utf8sep = "\N{ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM}".encode()
text = b"GET /ligature HTTP/1" + utf8sep + b"1\r\n\r\n"
with pytest.raises(http_exceptions.BadStatusLine):
parser.feed_data(text)
Expand Down Expand Up @@ -913,7 +913,7 @@ def test_http_request_parser_utf8_request_line(parser: HttpRequestParser) -> Non
b"GET /P\xc3\xbcnktchen\xa0\xef\xb7 HTTP/1.1\r\n" +
# for easier grep: ASCII 0xA0 more commonly known as non-breaking space
# note the leading and trailing spaces
"sTeP: \N{latin small letter sharp s}nek\t\N{no-break space} "
"sTeP: \N{LATIN SMALL LETTER SHARP S}nek\t\N{NO-BREAK SPACE} "
"\r\n\r\n".encode()
)
msg = messages[0][0]
Expand Down Expand Up @@ -1673,7 +1673,7 @@ async def test_parse_eof_payload(self, protocol: BaseProtocol) -> None:
p.feed_eof()

assert out.is_eof()
assert [(bytearray(b"data"))] == list(out._buffer)
assert [bytearray(b"data")] == list(out._buffer)

async def test_parse_length_payload_eof(self, protocol: BaseProtocol) -> None:
out = aiohttp.StreamReader(protocol, 2**16, loop=asyncio.get_running_loop())
Expand Down
24 changes: 12 additions & 12 deletions tests/test_proxy_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ async def proxy_server() -> mock.Mock:


async def test_proxy_http_absolute_path(
proxy_test_server: Callable[[], Awaitable[mock.Mock]]
proxy_test_server: Callable[[], Awaitable[mock.Mock]],
) -> None:
url = "http://aiohttp.io/path?query=yes"
proxy = await proxy_test_server()
Expand All @@ -306,7 +306,7 @@ async def test_proxy_http_absolute_path(


async def test_proxy_http_raw_path(
proxy_test_server: Callable[[], Awaitable[mock.Mock]]
proxy_test_server: Callable[[], Awaitable[mock.Mock]],
) -> None:
url = "http://aiohttp.io:2561/space sheep?q=can:fly"
raw_url = "/space%20sheep?q=can:fly"
Expand All @@ -319,7 +319,7 @@ async def test_proxy_http_raw_path(


async def test_proxy_http_idna_support(
proxy_test_server: Callable[[], Awaitable[mock.Mock]]
proxy_test_server: Callable[[], Awaitable[mock.Mock]],
) -> None:
url = "http://éé.com/"
proxy = await proxy_test_server()
Expand All @@ -339,7 +339,7 @@ async def test_proxy_http_connection_error() -> None:


async def test_proxy_http_bad_response(
proxy_test_server: Callable[[], Awaitable[mock.Mock]]
proxy_test_server: Callable[[], Awaitable[mock.Mock]],
) -> None:
url = "http://aiohttp.io/path"
proxy = await proxy_test_server()
Expand All @@ -352,7 +352,7 @@ async def test_proxy_http_bad_response(


async def test_proxy_http_auth(
proxy_test_server: Callable[[], Awaitable[mock.Mock]]
proxy_test_server: Callable[[], Awaitable[mock.Mock]],
) -> None:
url = "http://aiohttp.io/path"
proxy = await proxy_test_server()
Expand Down Expand Up @@ -380,7 +380,7 @@ async def test_proxy_http_auth(


async def test_proxy_http_auth_utf8(
proxy_test_server: Callable[[], Awaitable[mock.Mock]]
proxy_test_server: Callable[[], Awaitable[mock.Mock]],
) -> None:
url = "http://aiohttp.io/path"
auth = aiohttp.BasicAuth("юзер", "пасс", "utf-8")
Expand All @@ -393,7 +393,7 @@ async def test_proxy_http_auth_utf8(


async def test_proxy_http_auth_from_url(
proxy_test_server: Callable[[], Awaitable[mock.Mock]]
proxy_test_server: Callable[[], Awaitable[mock.Mock]],
) -> None:
url = "http://aiohttp.io/path"
proxy = await proxy_test_server()
Expand Down Expand Up @@ -492,7 +492,7 @@ async def request(pid: int) -> ClientResponse:

@pytest.mark.xfail
async def test_proxy_https_connect(
proxy_test_server: Callable[[], Awaitable[mock.Mock]]
proxy_test_server: Callable[[], Awaitable[mock.Mock]],
) -> None:
proxy = await proxy_test_server()
url = "https://www.google.com.ua/search?q=aiohttp proxy"
Expand All @@ -510,7 +510,7 @@ async def test_proxy_https_connect(

@pytest.mark.xfail
async def test_proxy_https_connect_with_port(
proxy_test_server: Callable[[], Awaitable[mock.Mock]]
proxy_test_server: Callable[[], Awaitable[mock.Mock]],
) -> None:
proxy = await proxy_test_server()
url = "https://secure.aiohttp.io:2242/path"
Expand Down Expand Up @@ -545,7 +545,7 @@ async def test_proxy_https_send_body(

@pytest.mark.xfail
async def test_proxy_https_idna_support(
proxy_test_server: Callable[[], Awaitable[mock.Mock]]
proxy_test_server: Callable[[], Awaitable[mock.Mock]],
) -> None:
url = "https://éé.com/"
proxy = await proxy_test_server()
Expand All @@ -567,7 +567,7 @@ async def test_proxy_https_connection_error() -> None:


async def test_proxy_https_bad_response(
proxy_test_server: Callable[[], Awaitable[mock.Mock]]
proxy_test_server: Callable[[], Awaitable[mock.Mock]],
) -> None:
url = "https://secure.aiohttp.io/path"
proxy = await proxy_test_server()
Expand All @@ -584,7 +584,7 @@ async def test_proxy_https_bad_response(

@pytest.mark.xfail
async def test_proxy_https_auth(
proxy_test_server: Callable[[], Awaitable[mock.Mock]]
proxy_test_server: Callable[[], Awaitable[mock.Mock]],
) -> None:
url = "https://secure.aiohttp.io/path"
auth = aiohttp.BasicAuth("user", "pass")
Expand Down
Loading