commit:     60d6e393f7bb9c2a957df54b91c970448b8b9194
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat Oct  4 17:20:06 2025 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat Oct  4 17:30:26 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=60d6e393

dev-python/aiohttp-socks: Fix tests with pytest-asyncio-1

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 .../aiohttp-socks/aiohttp-socks-0.10.1.ebuild      | 10 ++-
 .../files/aiohttp-socks-0.10.1-test.patch          | 96 ++++++++++++++++++++++
 2 files changed, 104 insertions(+), 2 deletions(-)

diff --git a/dev-python/aiohttp-socks/aiohttp-socks-0.10.1.ebuild 
b/dev-python/aiohttp-socks/aiohttp-socks-0.10.1.ebuild
index 4fb851b7e12b..da7b19de7fec 100644
--- a/dev-python/aiohttp-socks/aiohttp-socks-0.10.1.ebuild
+++ b/dev-python/aiohttp-socks/aiohttp-socks-0.10.1.ebuild
@@ -4,7 +4,7 @@
 EAPI=8
 
 DISTUTILS_USE_PEP517=setuptools
-PYTHON_COMPAT=( python3_{10..13} pypy3 pypy3_11 )
+PYTHON_COMPAT=( python3_{11..13} pypy3_11 )
 
 inherit distutils-r1
 
@@ -28,7 +28,6 @@ RDEPEND="
 "
 BDEPEND="
        test? (
-               dev-python/pytest-asyncio[${PYTHON_USEDEP}]
                dev-python/trustme[${PYTHON_USEDEP}]
                dev-python/attrs[${PYTHON_USEDEP}]
                dev-python/yarl[${PYTHON_USEDEP}]
@@ -37,4 +36,11 @@ BDEPEND="
        )
 "
 
+EPYTEST_PLUGINS=( pytest-asyncio )
 distutils_enable_tests pytest
+
+PATCHES=(
+       # https://github.com/romis2012/aiohttp-socks/pull/53
+       # 
https://github.com/romis2012/aiohttp-socks/commit/0d8800233dc8aa7384abaf02ebf3543d3d2dea97
+       "${FILESDIR}/${P}-test.patch"
+)

diff --git a/dev-python/aiohttp-socks/files/aiohttp-socks-0.10.1-test.patch 
b/dev-python/aiohttp-socks/files/aiohttp-socks-0.10.1-test.patch
new file mode 100644
index 000000000000..fa9ae3963c62
--- /dev/null
+++ b/dev-python/aiohttp-socks/files/aiohttp-socks-0.10.1-test.patch
@@ -0,0 +1,96 @@
+From 2ef7cba5f8d47d059d666683e7dcf01af214596f Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <[email protected]>
+Date: Sat, 4 Oct 2025 19:17:44 +0200
+Subject: [PATCH] Fix test compatibility with pytest-asyncio >= 1.0.0
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Replace the obsolete `event_loop` fixture with
+`asyncio.get_running_loop()`, to fix testing with newer versions
+of `pytest-asyncio`.  This change is backwards compatible.
+
+Signed-off-by: Michał Górny <[email protected]>
+---
+ tests/test_connector.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tests/test_connector.py b/tests/test_connector.py
+index 988fc20..e24ef48 100644
+--- a/tests/test_connector.py
++++ b/tests/test_connector.py
+@@ -272,7 +272,6 @@ async def test_socks5_open_connection(url, rdns, 
target_ssl_context):
+ async def test_socks5_http_create_connection(
+     url: str,
+     rdns: bool,
+-    event_loop: asyncio.AbstractEventLoop,
+     target_ssl_context: ssl.SSLContext,
+ ):
+     url = URL(url)
+@@ -281,6 +280,7 @@ async def test_socks5_http_create_connection(
+     if url.scheme == 'https':
+         ssl_context = target_ssl_context
+ 
++    event_loop = asyncio.get_running_loop()
+     reader = asyncio.StreamReader(loop=event_loop)
+     protocol = asyncio.StreamReaderProtocol(reader, loop=event_loop)
+ 
+From 0d8800233dc8aa7384abaf02ebf3543d3d2dea97 Mon Sep 17 00:00:00 2001
+From: Roman Snegirev <[email protected]>
+Date: Mon, 26 May 2025 13:14:40 +0300
+Subject: [PATCH] Fix tests, update README
+
+diff --git a/tests/test_connector.py b/tests/test_connector.py
+index 8692fe6..988fc20 100644
+--- a/tests/test_connector.py
++++ b/tests/test_connector.py
+@@ -35,6 +35,16 @@
+ )
+ 
+ 
++def is_proxy_connection_error(e: Exception):
++    return isinstance(e, ProxyConnectionError) or isinstance(
++        e.__cause__, ProxyConnectionError
++    )
++
++
++def is_proxy_timeout_error(e: Exception):
++    return isinstance(e, ProxyTimeoutError) or isinstance(e.__cause__, 
ProxyTimeoutError)
++
++
+ async def fetch(
+     connector: TCPConnector,
+     url: str,
+@@ -105,13 +115,15 @@ async def 
test_socks5_proxy_with_timeout(target_ssl_context):
+ async def test_socks5_proxy_with_proxy_connect_timeout(target_ssl_context):
+     connector = ProxyConnector.from_url(SOCKS5_IPV4_URL)
+     timeout = aiohttp.ClientTimeout(total=32, sock_connect=0.001)
+-    with pytest.raises(ProxyTimeoutError):
++    # with pytest.raises(ProxyTimeoutError):
++    with pytest.raises(Exception) as exc_info:
+         await fetch(
+             connector=connector,
+             url=TEST_URL_IPV4,
+             timeout=timeout,
+             ssl_context=target_ssl_context,
+         )
++    assert is_proxy_timeout_error(exc_info.value)
+ 
+ 
+ @pytest.mark.asyncio
+@@ -123,12 +135,14 @@ async def 
test_socks5_proxy_with_invalid_proxy_port(unused_tcp_port, target_ssl_
+         username=LOGIN,
+         password=PASSWORD,
+     )
+-    with pytest.raises(ProxyConnectionError):
++    # with pytest.raises(ProxyConnectionError):
++    with pytest.raises(Exception) as exc_info:
+         await fetch(
+             connector=connector,
+             url=TEST_URL_IPV4,
+             ssl_context=target_ssl_context,
+         )
++    assert is_proxy_connection_error(exc_info.value)
+ 
+ 
+ @pytest.mark.parametrize('url', (TEST_URL_IPV4, TEST_URL_IPV4_HTTPS))

Reply via email to