commit:     9198e2f3f832b7276471c601720f0e9a086e445b
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Tue Sep  2 12:57:00 2025 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Tue Sep  2 12:57:00 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9198e2f3

dev-python/aiorpcx: Backport test fixes for pytest-asyncio-1

Closes: https://bugs.gentoo.org/961266
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 dev-python/aiorpcx/aiorpcx-0.23.1.ebuild           |  13 +-
 dev-python/aiorpcx/aiorpcx-0.24.ebuild             |   9 +-
 dev-python/aiorpcx/aiorpcx-0.25.0.ebuild           |   7 +-
 .../aiorpcx-0.23.1-pytest-asyncio-1-more.patch     |  73 ++++++++++
 .../files/aiorpcx-0.25.0-pytest-asyncio-1.patch    | 152 +++++++++++++++++++++
 5 files changed, 249 insertions(+), 5 deletions(-)

diff --git a/dev-python/aiorpcx/aiorpcx-0.23.1.ebuild 
b/dev-python/aiorpcx/aiorpcx-0.23.1.ebuild
index 14fc42a3f534..0856c05b7269 100644
--- a/dev-python/aiorpcx/aiorpcx-0.23.1.ebuild
+++ b/dev-python/aiorpcx/aiorpcx-0.23.1.ebuild
@@ -4,7 +4,7 @@
 EAPI=8
 
 DISTUTILS_USE_PEP517=setuptools
-PYTHON_COMPAT=( python3_{10..13} )
+PYTHON_COMPAT=( python3_{11..13} )
 
 inherit distutils-r1
 
@@ -26,15 +26,24 @@ KEYWORDS="amd64 ~arm arm64 x86"
 
 BDEPEND="
        test? (
-               dev-python/pytest-asyncio[${PYTHON_USEDEP}]
                dev-python/uvloop[${PYTHON_USEDEP}]
                dev-python/websockets[${PYTHON_USEDEP}]
        )
 "
 
+EPYTEST_PLUGINS=( pytest-asyncio )
 distutils_enable_tests pytest
 
 EPYTEST_DESELECT=(
        # require Internet
        tests/test_socks.py::TestSOCKSProxy::test_create_connection_resolve_good
 )
+
+PATCHES=(
+       # 
https://github.com/kyuupichan/aiorpcX/commit/b8ce32889c45c98b44c4e247ec0b0ae206e9ee91
+       "${FILESDIR}/${PN}-0.25.0-pytest-asyncio-1.patch"
+       # parts of
+       # 
https://github.com/kyuupichan/aiorpcX/commit/b973b9b5612a47fe6311b43a4a4a2227b179d9b0
+       # 
https://github.com/kyuupichan/aiorpcX/commit/b3fe21c9ad6f21967b31422174ab648263d6d4d7
+       "${FILESDIR}/${P}-pytest-asyncio-1-more.patch"
+)

diff --git a/dev-python/aiorpcx/aiorpcx-0.24.ebuild 
b/dev-python/aiorpcx/aiorpcx-0.24.ebuild
index db14b9d5122c..542cf042033c 100644
--- a/dev-python/aiorpcx/aiorpcx-0.24.ebuild
+++ b/dev-python/aiorpcx/aiorpcx-0.24.ebuild
@@ -4,7 +4,7 @@
 EAPI=8
 
 DISTUTILS_USE_PEP517=setuptools
-PYTHON_COMPAT=( python3_{10..13} )
+PYTHON_COMPAT=( python3_{11..13} )
 
 inherit distutils-r1
 
@@ -26,15 +26,20 @@ KEYWORDS="amd64 ~arm arm64 x86"
 
 BDEPEND="
        test? (
-               dev-python/pytest-asyncio[${PYTHON_USEDEP}]
                dev-python/uvloop[${PYTHON_USEDEP}]
                >=dev-python/websockets-0.14[${PYTHON_USEDEP}]
        )
 "
 
+EPYTEST_PLUGINS=( pytest-asyncio )
 distutils_enable_tests pytest
 
 EPYTEST_DESELECT=(
        # require Internet
        tests/test_socks.py::TestSOCKSProxy::test_create_connection_resolve_good
 )
+
+PATCHES=(
+       # 
https://github.com/kyuupichan/aiorpcX/commit/b8ce32889c45c98b44c4e247ec0b0ae206e9ee91
+       "${FILESDIR}/${PN}-0.25.0-pytest-asyncio-1.patch"
+)

diff --git a/dev-python/aiorpcx/aiorpcx-0.25.0.ebuild 
b/dev-python/aiorpcx/aiorpcx-0.25.0.ebuild
index 750ee66ddbb5..a87e4570816f 100644
--- a/dev-python/aiorpcx/aiorpcx-0.25.0.ebuild
+++ b/dev-python/aiorpcx/aiorpcx-0.25.0.ebuild
@@ -26,15 +26,20 @@ KEYWORDS="amd64 ~arm arm64 x86"
 
 BDEPEND="
        test? (
-               dev-python/pytest-asyncio[${PYTHON_USEDEP}]
                dev-python/uvloop[${PYTHON_USEDEP}]
                >=dev-python/websockets-0.14[${PYTHON_USEDEP}]
        )
 "
 
+EPYTEST_PLUGINS=( pytest-asyncio )
 distutils_enable_tests pytest
 
 EPYTEST_DESELECT=(
        # require Internet
        tests/test_socks.py::TestSOCKSProxy::test_create_connection_resolve_good
 )
+
+PATCHES=(
+       # 
https://github.com/kyuupichan/aiorpcX/commit/b8ce32889c45c98b44c4e247ec0b0ae206e9ee91
+       "${FILESDIR}/${P}-pytest-asyncio-1.patch"
+)

diff --git 
a/dev-python/aiorpcx/files/aiorpcx-0.23.1-pytest-asyncio-1-more.patch 
b/dev-python/aiorpcx/files/aiorpcx-0.23.1-pytest-asyncio-1-more.patch
new file mode 100644
index 000000000000..5a0ef6459c67
--- /dev/null
+++ b/dev-python/aiorpcx/files/aiorpcx-0.23.1-pytest-asyncio-1-more.patch
@@ -0,0 +1,73 @@
+From b973b9b5612a47fe6311b43a4a4a2227b179d9b0 Mon Sep 17 00:00:00 2001
+From: f321x <[email protected]>
+Date: Thu, 16 Jan 2025 12:04:06 +0100
+Subject: [PATCH 1/2] bump ws version to 14 and python version to 3.9
+
+remove venv
+
+bump ws version to 14 and python version to 3.9
+
+remove .idea
+
+bump ws version to 14 and python version to 3.9
+---
+ tests/test_websocket.py | 17 +++++------------
+ 1 file changed, 5 insertions(+), 12 deletions(-)
+
+diff --git a/tests/test_websocket.py b/tests/test_websocket.py
+index a0d268d..97b049c 100755
+--- a/tests/test_websocket.py
++++ b/tests/test_websocket.py
+@@ -7,19 +7,12 @@ from aiorpcx import connect_ws, NetAddress, serve_ws
+ from test_session import MyServerSession
+ 
+ 
[email protected]
+-def ws_server(unused_tcp_port, event_loop):
+-    coro = serve_ws(MyServerSession, 'localhost', unused_tcp_port)
+-    server = event_loop.run_until_complete(coro)
[email protected](scope="function")
++async def ws_server(unused_tcp_port, event_loop):
++    server = await serve_ws(MyServerSession, 'localhost', unused_tcp_port)
+     yield f'ws://localhost:{unused_tcp_port}'
+-    tasks = asyncio.all_tasks(event_loop)
+-
+-    async def close_all():
+-        server.close()
+-        await server.wait_closed()
+-        if tasks:
+-            await asyncio.wait(tasks)
+-    event_loop.run_until_complete(close_all())
++    server.close()
++    await server.wait_closed()
+ 
+ 
+ @pytest.mark.filterwarnings("ignore:'with .*:DeprecationWarning")
+From b3fe21c9ad6f21967b31422174ab648263d6d4d7 Mon Sep 17 00:00:00 2001
+From: Neil Booth <[email protected]>
+Date: Thu, 16 Jan 2025 11:51:14 +0000
+Subject: [PATCH 2/2] Further tweaks.
+
+---
+ tests/test_websocket.py | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/tests/test_websocket.py b/tests/test_websocket.py
+index 97b049c..9a8f77a 100755
+--- a/tests/test_websocket.py
++++ b/tests/test_websocket.py
+@@ -1,5 +1,3 @@
+-import asyncio
+-
+ import pytest
+ 
+ from aiorpcx import connect_ws, NetAddress, serve_ws
+@@ -8,7 +6,7 @@ from test_session import MyServerSession
+ 
+ 
+ @pytest.fixture(scope="function")
+-async def ws_server(unused_tcp_port, event_loop):
++async def ws_server(unused_tcp_port):
+     server = await serve_ws(MyServerSession, 'localhost', unused_tcp_port)
+     yield f'ws://localhost:{unused_tcp_port}'
+     server.close()

diff --git a/dev-python/aiorpcx/files/aiorpcx-0.25.0-pytest-asyncio-1.patch 
b/dev-python/aiorpcx/files/aiorpcx-0.25.0-pytest-asyncio-1.patch
new file mode 100644
index 000000000000..4f8a94d2926c
--- /dev/null
+++ b/dev-python/aiorpcx/files/aiorpcx-0.25.0-pytest-asyncio-1.patch
@@ -0,0 +1,152 @@
+From b8ce32889c45c98b44c4e247ec0b0ae206e9ee91 Mon Sep 17 00:00:00 2001
+From: Neil Booth <[email protected]>
+Date: Wed, 30 Jul 2025 14:41:44 -0400
+Subject: [PATCH] Remove event_loop fixture usage from tests
+
+---
+ tests/test_session.py    | 43 +++++++++-------------------------------
+ tests/test_socks.py      |  6 +++---
+ tests/test_unixsocket.py | 16 +++++----------
+ tests/test_util.py       |  3 ++-
+ 4 files changed, 19 insertions(+), 49 deletions(-)
+
+diff --git a/tests/test_session.py b/tests/test_session.py
+index 8877fca..f52ab6b 100755
+--- a/tests/test_session.py
++++ b/tests/test_session.py
+@@ -17,13 +17,6 @@ from aiorpcx.session import Concurrency
+ from util import RaiseTest
+ 
+ 
+-if sys.version_info >= (3, 7):
+-    from asyncio import all_tasks
+-else:
+-    from asyncio import Task
+-    all_tasks = Task.all_tasks
+-
+-
+ def raises_method_not_found(message):
+     return RaiseTest(JSONRPC.METHOD_NOT_FOUND, message, RPCError)
+ 
+@@ -86,21 +79,12 @@ def caplog_count(caplog, message):
+ 
+ 
+ @pytest.fixture
+-def server_port(unused_tcp_port, event_loop):
+-    coro = serve_rs(MyServerSession, 'localhost', unused_tcp_port, 
loop=event_loop)
+-    server = event_loop.run_until_complete(coro)
++async def server_port(unused_tcp_port):
++    server = await serve_rs(MyServerSession, 'localhost', unused_tcp_port)
+     yield unused_tcp_port
+-    if hasattr(asyncio, 'all_tasks'):
+-        tasks = asyncio.all_tasks(event_loop)
+-    else:
+-        tasks = asyncio.Task.all_tasks(loop=event_loop)
+ 
+-    async def close_all():
+-        server.close()
+-        await server.wait_closed()
+-        if tasks:
+-            await asyncio.wait(tasks)
+-    event_loop.run_until_complete(close_all())
++    server.close()
++    await server.wait_closed()
+ 
+ 
+ class TestRPCSession:
+@@ -765,21 +749,12 @@ class MessageServer(MessageSession):
+ 
+ 
+ @pytest.fixture
+-def msg_server_port(event_loop, unused_tcp_port):
+-    coro = serve_rs(MessageServer, 'localhost', unused_tcp_port, 
loop=event_loop)
+-    server = event_loop.run_until_complete(coro)
++async def msg_server_port(unused_tcp_port):
++    server = await serve_rs(MessageServer, 'localhost', unused_tcp_port)
+     yield unused_tcp_port
+-    if hasattr(asyncio, 'all_tasks'):
+-        tasks = asyncio.all_tasks(event_loop)
+-    else:
+-        tasks = asyncio.Task.all_tasks(loop=event_loop)
+-
+-    async def close_all():
+-        server.close()
+-        await server.wait_closed()
+-        if tasks:
+-            await asyncio.wait(tasks)
+-    event_loop.run_until_complete(close_all())
++
++    server.close()
++    await server.wait_closed()
+ 
+ 
+ def connect_message_session(host, port, proxy=None, framer=None):
+diff --git a/tests/test_socks.py b/tests/test_socks.py
+index 43ca282..a8d3af2 100755
+--- a/tests/test_socks.py
++++ b/tests/test_socks.py
+@@ -482,10 +482,10 @@ localhosts = ['127.0.0.1', '::1', 'localhost']
+ 
+ 
+ @pytest.fixture(params=localhosts)
+-def proxy_address(request, event_loop, unused_tcp_port):
++async def proxy_address(request, unused_tcp_port):
+     host = request.param
+-    coro = event_loop.create_server(FakeServer, host=host, 
port=unused_tcp_port)
+-    server = event_loop.run_until_complete(coro)
++    event_loop = asyncio.get_running_loop()
++    server = await event_loop.create_server(FakeServer, host=host, 
port=unused_tcp_port)
+     yield NetAddress(host, unused_tcp_port)
+     server.close()
+ 
+diff --git a/tests/test_unixsocket.py b/tests/test_unixsocket.py
+index f75f23d..ae8c27f 100755
+--- a/tests/test_unixsocket.py
++++ b/tests/test_unixsocket.py
+@@ -11,20 +11,14 @@ if sys.platform.startswith("win"):
+ 
+ 
+ @pytest.fixture
+-def us_server(event_loop):
++async def us_server():
++    event_loop = asyncio.get_running_loop()
+     with tempfile.TemporaryDirectory() as tmp_folder:
+         socket_path = path.join(tmp_folder, 'test.socket')
+-        coro = serve_us(MyServerSession, socket_path, loop=event_loop)
+-        server = event_loop.run_until_complete(coro)
++        server = await serve_us(MyServerSession, socket_path)
+         yield socket_path
+-        tasks = asyncio.all_tasks(event_loop)
+-
+-        async def close_all():
+-            server.close()
+-            await server.wait_closed()
+-            if tasks:
+-                await asyncio.wait(tasks)
+-        event_loop.run_until_complete(close_all())
++        server.close()
++        await server.wait_closed()
+ 
+ 
+ class TestUSTransport:
+diff --git a/tests/test_util.py b/tests/test_util.py
+index 8ce9691..5980607 100755
+--- a/tests/test_util.py
++++ b/tests/test_util.py
+@@ -15,6 +15,7 @@ async def coro(x, y):
+ 
+ 
+ def test_is_async_call():
++    event_loop = asyncio.new_event_loop()
+     z = coro(2, 3)
+     assert not is_async_call(z)
+     assert is_async_call(coro)
+@@ -23,7 +24,7 @@ def test_is_async_call():
+     assert not is_async_call(test_is_async_call)
+     assert not is_async_call(partial(is_async_call))
+     # Lose a warning
+-    asyncio.get_event_loop().run_until_complete(z)
++    event_loop.run_until_complete(z)
+ 
+ 
+ @pytest.mark.parametrize("hostname,answer", (

Reply via email to