- Add remove-re-assert.patch, we really don’t need beautifuly

presented exceptions for our testing; remove re-assert BR.

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-aiohttp?expand=0&rev=102
This commit is contained in:
Matej Cepl 2023-10-14 17:33:08 +00:00 committed by Git OBS Bridge
parent 015984a408
commit 4bc5709bac
3 changed files with 208 additions and 2 deletions

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Sat Oct 14 17:27:26 UTC 2023 - Matej Cepl <mcepl@cepl.eu>
- Add remove-re-assert.patch, we really dont need beautifuly
presented exceptions for our testing; remove re-assert BR.
-------------------------------------------------------------------
Mon Sep 11 20:43:01 UTC 2023 - Dirk Müller <dmueller@suse.com>

View File

@ -28,7 +28,10 @@ License: Apache-2.0
URL: https://github.com/aio-libs/aiohttp
Source: https://files.pythonhosted.org/packages/source/a/aiohttp/aiohttp-%{version}.tar.gz
# PATCH-FIX-UPSTREAM Update-update_query-calls-to-work-with-latest-yarl.patch gh#aio-libs/aiohttp#7260
Patch1: Update-update_query-calls-to-work-with-latest-yarl.patch
Patch0: Update-update_query-calls-to-work-with-latest-yarl.patch
# PATCH-FIX-OPENSUSE remove-re-assert.patch mcepl@suse.com
# We really dont need beautifuly presented exceptions for our testing
Patch1: remove-re-assert.patch
Requires: python-aiosignal >= 1.1.2
Requires: python-attrs >= 17.3.0
Requires: python-frozenlist >= 1.1.1
@ -75,7 +78,6 @@ BuildRequires: %{python_module proxy.py}
BuildRequires: %{python_module pytest >= 6.2.0}
BuildRequires: %{python_module pytest-mock}
BuildRequires: %{python_module pytest-timeout}
BuildRequires: %{python_module re-assert}
BuildRequires: %{python_module trustme}
# /SECTION
# SECTION docs

198
remove-re-assert.patch Normal file
View File

@ -0,0 +1,198 @@
---
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(-)
--- a/tests/test_client_session.py
+++ b/tests/test_client_session.py
@@ -3,6 +3,7 @@ import contextlib
import gc
import io
import json
+import re
import sys
from http.cookies import SimpleCookie
from typing import Any, List
@@ -10,7 +11,6 @@ from unittest import mock
import pytest
from multidict import CIMultiDict, MultiDict
-from re_assert import Matches
from yarl import URL
import aiohttp
@@ -322,8 +322,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())
--- a/tests/test_streams.py
+++ b/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
from aiohttp.helpers import PY_311
@@ -1075,7 +1075,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
--- a/tests/test_urldispatch.py
+++ b/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:
--- a/tests/test_web_response.py
+++ b/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:
@@ -776,7 +778,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=/"
@@ -828,7 +830,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:
@@ -1069,14 +1071,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)
)
@@ -1089,15 +1090,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)
)
@@ -1111,15 +1110,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)
)