forked from pool/python-aiohttp
* Introduced ``AppKey`` for static typing support of ``Application`` storage. * Added a graceful shutdown period which allows pending tasks to complete before the application's cleanup is called. * Added `handler_cancellation`_ parameter to cancel web handler on client disconnection. * This (optionally) reintroduces a feature removed in a previous release. * Recommended for those looking for an extra level of protection against denial-of-service attacks. * Added support for setting response header parameters ``max_line_size`` and ``max_field_size``. * Added ``auto_decompress`` parameter to ``ClientSession.request`` to override ``ClientSession._auto_decompress``. * Changed ``raise_for_status`` to allow a coroutine. * Added client brotli compression support (optional with runtime check). * Added ``client_max_size`` to ``BaseRequest.clone()`` to allow overriding the request body size. -- :user:`anesabml`. * Added a middleware type alias ``aiohttp.typedefs.Middleware``. * Exported ``HTTPMove`` which can be used to catch any redirection request that has a location -- :user:`dreamsorcerer`. * Changed the ``path`` parameter in ``web.run_app()`` to accept a ``pathlib.Path`` object. * Performance: Skipped filtering ``CookieJar`` when the jar is empty or all cookies have expired. * Performance: Only check origin if insecure scheme and there OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-aiohttp?expand=0&rev=106
207 lines
6.6 KiB
Diff
207 lines
6.6 KiB
Diff
---
|
|
tests/test_client_session.py | 6 +++---
|
|
tests/test_streams.py | 4 ++--
|
|
tests/test_urldispatch.py | 7 +++----
|
|
tests/test_web_response.py | 27 ++++++++++++---------------
|
|
4 files changed, 20 insertions(+), 24 deletions(-)
|
|
|
|
Index: aiohttp-3.9.0/tests/test_client_session.py
|
|
===================================================================
|
|
--- aiohttp-3.9.0.orig/tests/test_client_session.py
|
|
+++ aiohttp-3.9.0/tests/test_client_session.py
|
|
@@ -2,6 +2,7 @@ import asyncio
|
|
import contextlib
|
|
import gc
|
|
import io
|
|
+import re
|
|
import json
|
|
from http.cookies import SimpleCookie
|
|
from typing import Any, List
|
|
@@ -9,7 +10,6 @@ from unittest import mock
|
|
|
|
import pytest
|
|
from multidict import CIMultiDict, MultiDict
|
|
-from re_assert import Matches
|
|
from yarl import URL
|
|
|
|
import aiohttp
|
|
@@ -320,8 +320,8 @@ def test_connector_loop(loop) -> None:
|
|
|
|
loop.run_until_complete(make_sess())
|
|
assert (
|
|
- Matches("Session and connector has to use same event loop")
|
|
- == str(ctx.value).strip()
|
|
+ re.match("Session and connector has to use same event loop",
|
|
+ str(ctx.value).strip())
|
|
)
|
|
another_loop.run_until_complete(connector.close())
|
|
|
|
Index: aiohttp-3.9.0/tests/test_streams.py
|
|
===================================================================
|
|
--- aiohttp-3.9.0.orig/tests/test_streams.py
|
|
+++ aiohttp-3.9.0/tests/test_streams.py
|
|
@@ -3,13 +3,13 @@
|
|
import abc
|
|
import asyncio
|
|
import gc
|
|
+import re
|
|
import types
|
|
from collections import defaultdict
|
|
from itertools import groupby
|
|
from unittest import mock
|
|
|
|
import pytest
|
|
-from re_assert import Matches
|
|
|
|
from aiohttp import streams
|
|
|
|
@@ -1102,7 +1102,7 @@ class TestStreamReader:
|
|
loop = asyncio.get_event_loop()
|
|
stream = self._make_one()
|
|
stream._waiter = loop.create_future()
|
|
- assert Matches(r"<StreamReader w=<Future pending[\S ]*>>") == repr(stream)
|
|
+ assert re.match(r"<StreamReader w=<Future pending[\S ]*>>", repr(stream))
|
|
stream._waiter.set_result(None)
|
|
await stream._waiter
|
|
stream._waiter = None
|
|
Index: aiohttp-3.9.0/tests/test_urldispatch.py
|
|
===================================================================
|
|
--- aiohttp-3.9.0.orig/tests/test_urldispatch.py
|
|
+++ aiohttp-3.9.0/tests/test_urldispatch.py
|
|
@@ -5,7 +5,6 @@ from collections.abc import Container, I
|
|
from urllib.parse import unquote
|
|
|
|
import pytest
|
|
-from re_assert import Matches
|
|
from yarl import URL
|
|
|
|
import aiohttp
|
|
@@ -313,7 +312,7 @@ def test_double_add_url_with_the_same_na
|
|
regexp = "Duplicate 'name', already handled by"
|
|
with pytest.raises(ValueError) as ctx:
|
|
router.add_route("GET", "/get_other", handler2, name="name")
|
|
- assert Matches(regexp) == str(ctx.value)
|
|
+ assert re.match(regexp, str(ctx.value))
|
|
|
|
|
|
def test_route_plain(router) -> None:
|
|
@@ -504,7 +503,7 @@ def test_contains(router) -> None:
|
|
|
|
def test_static_repr(router) -> None:
|
|
router.add_static("/get", os.path.dirname(aiohttp.__file__), name="name")
|
|
- assert Matches(r"<StaticResource 'name' /get") == repr(router["name"])
|
|
+ assert re.match(r"<StaticResource 'name' /get", repr(router["name"]))
|
|
|
|
|
|
def test_static_adds_slash(router) -> None:
|
|
@@ -626,7 +625,7 @@ async def test_regular_match_info(router
|
|
req = make_mocked_request("GET", "/get/john")
|
|
match_info = await router.resolve(req)
|
|
assert {"name": "john"} == match_info
|
|
- assert Matches("<MatchInfo {'name': 'john'}: .+<Dynamic.+>>") == repr(match_info)
|
|
+ assert re.match("<MatchInfo {'name': 'john'}: .+<Dynamic.+>>", repr(match_info))
|
|
|
|
|
|
async def test_match_info_with_plus(router) -> None:
|
|
Index: aiohttp-3.9.0/tests/test_web_response.py
|
|
===================================================================
|
|
--- aiohttp-3.9.0.orig/tests/test_web_response.py
|
|
+++ aiohttp-3.9.0/tests/test_web_response.py
|
|
@@ -2,13 +2,13 @@ import collections.abc
|
|
import datetime
|
|
import gzip
|
|
import json
|
|
+import re
|
|
from concurrent.futures import ThreadPoolExecutor
|
|
from unittest import mock
|
|
|
|
import aiosignal
|
|
import pytest
|
|
from multidict import CIMultiDict, CIMultiDictProxy
|
|
-from re_assert import Matches
|
|
|
|
from aiohttp import HttpVersion, HttpVersion10, HttpVersion11, hdrs
|
|
from aiohttp.helpers import ETag
|
|
@@ -401,7 +401,9 @@ async def test_chunked_encoding_forbidde
|
|
|
|
with pytest.raises(RuntimeError) as ctx:
|
|
await resp.prepare(req)
|
|
- assert Matches("Using chunked encoding is forbidden for HTTP/1.0") == str(ctx.value)
|
|
+ assert re.match(
|
|
+ "Using chunked encoding is forbidden for HTTP/1.0", str(ctx.value)
|
|
+ )
|
|
|
|
|
|
async def test_compression_no_accept() -> None:
|
|
@@ -843,7 +845,7 @@ def test_response_cookies() -> None:
|
|
'Set-Cookie: name=("")?; '
|
|
"expires=Thu, 01 Jan 1970 00:00:00 GMT; Max-Age=0; Path=/"
|
|
)
|
|
- assert Matches(expected) == str(resp.cookies)
|
|
+ assert re.match(expected, str(resp.cookies))
|
|
|
|
resp.set_cookie("name", "value", domain="local.host")
|
|
expected = "Set-Cookie: name=value; Domain=local.host; Path=/"
|
|
@@ -895,7 +897,7 @@ def test_response_cookie__issue_del_cook
|
|
'Set-Cookie: name=("")?; '
|
|
"expires=Thu, 01 Jan 1970 00:00:00 GMT; Max-Age=0; Path=/"
|
|
)
|
|
- assert Matches(expected) == str(resp.cookies)
|
|
+ assert re.match(expected, str(resp.cookies))
|
|
|
|
|
|
def test_cookie_set_after_del() -> None:
|
|
@@ -1136,14 +1138,13 @@ async def test_send_headers_for_empty_bo
|
|
await resp.write_eof()
|
|
txt = buf.decode("utf8")
|
|
assert (
|
|
- Matches(
|
|
+ re.match(
|
|
"HTTP/1.1 200 OK\r\n"
|
|
"Content-Length: 0\r\n"
|
|
"Content-Type: application/octet-stream\r\n"
|
|
"Date: .+\r\n"
|
|
"Server: .+\r\n\r\n"
|
|
- )
|
|
- == txt
|
|
+ , txt)
|
|
)
|
|
|
|
|
|
@@ -1156,15 +1157,13 @@ async def test_render_with_body(buf, wri
|
|
|
|
txt = buf.decode("utf8")
|
|
assert (
|
|
- Matches(
|
|
+ re.match(
|
|
"HTTP/1.1 200 OK\r\n"
|
|
"Content-Length: 4\r\n"
|
|
"Content-Type: application/octet-stream\r\n"
|
|
"Date: .+\r\n"
|
|
"Server: .+\r\n\r\n"
|
|
- "data"
|
|
- )
|
|
- == txt
|
|
+ "data", txt)
|
|
)
|
|
|
|
|
|
@@ -1178,15 +1177,13 @@ async def test_send_set_cookie_header(bu
|
|
|
|
txt = buf.decode("utf8")
|
|
assert (
|
|
- Matches(
|
|
+ re.match(
|
|
"HTTP/1.1 200 OK\r\n"
|
|
"Content-Length: 0\r\n"
|
|
"Set-Cookie: name=value\r\n"
|
|
"Content-Type: application/octet-stream\r\n"
|
|
"Date: .+\r\n"
|
|
- "Server: .+\r\n\r\n"
|
|
- )
|
|
- == txt
|
|
+ "Server: .+\r\n\r\n", txt)
|
|
)
|
|
|
|
|