Compare commits
3 Commits
| Author | SHA256 | Date | |
|---|---|---|---|
| 7e79b13fd7 | |||
| 3fc2f41d1c | |||
|
|
e14039ce15 |
159
0001-Remove-event_loop-fixture-usage-from-tests.patch
Normal file
159
0001-Remove-event_loop-fixture-usage-from-tests.patch
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
From: Neil Booth <kyuupichan@pm.me>
|
||||||
|
Date: Wed, 30 Jul 2025 14:41:44 -0400
|
||||||
|
Subject: Remove event_loop fixture usage from tests
|
||||||
|
References: event-loop-fix
|
||||||
|
Git-repo: https://github.com/kyuupichan/aiorpcX
|
||||||
|
Git-commit: b8ce32889c45c98b44c4e247ec0b0ae206e9ee91
|
||||||
|
Patch-mainline: yes
|
||||||
|
|
||||||
|
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
|
||||||
|
---
|
||||||
|
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 8877fca3e839..f52ab6b03018 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 43ca282d379e..a8d3af2d500d 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 f75f23db0369..ae8c27fc677c 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 8ce9691cd60d..5980607202a8 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", (
|
||||||
|
--
|
||||||
|
2.50.1
|
||||||
|
|
||||||
119
event_loop.patch
119
event_loop.patch
@@ -1,119 +0,0 @@
|
|||||||
From: Jiri Slaby <jslaby@suse.cz>
|
|
||||||
Date: Mon, 30 Sep 2024 08:42:26 +0200
|
|
||||||
Subject: don't use event_loop pytest-asyncio fixture
|
|
||||||
References: build-fix
|
|
||||||
Patch-mainline: reported, https://github.com/kyuupichan/aiorpcX/issues/55
|
|
||||||
|
|
||||||
event_loop fixture was deprecated and removed from pytest-asyncio 1.0.0.
|
|
||||||
Use the internal _function_event_loop for the time being. Hopefully this
|
|
||||||
will be fixed upstream eventually...
|
|
||||||
|
|
||||||
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
|
|
||||||
---
|
|
||||||
tests/test_session.py | 24 ++++++++++++------------
|
|
||||||
tests/test_socks.py | 6 +++---
|
|
||||||
tests/test_unixsocket.py | 10 +++++-----
|
|
||||||
3 files changed, 20 insertions(+), 20 deletions(-)
|
|
||||||
|
|
||||||
--- a/tests/test_session.py
|
|
||||||
+++ b/tests/test_session.py
|
|
||||||
@@ -86,21 +86,21 @@ 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)
|
|
||||||
+def server_port(unused_tcp_port, _function_event_loop):
|
|
||||||
+ coro = serve_rs(MyServerSession, 'localhost', unused_tcp_port, loop=_function_event_loop)
|
|
||||||
+ server = _function_event_loop.run_until_complete(coro)
|
|
||||||
yield unused_tcp_port
|
|
||||||
if hasattr(asyncio, 'all_tasks'):
|
|
||||||
- tasks = asyncio.all_tasks(event_loop)
|
|
||||||
+ tasks = asyncio.all_tasks(_function_event_loop)
|
|
||||||
else:
|
|
||||||
- tasks = asyncio.Task.all_tasks(loop=event_loop)
|
|
||||||
+ tasks = asyncio.Task.all_tasks(loop=_function_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())
|
|
||||||
+ _function_event_loop.run_until_complete(close_all())
|
|
||||||
|
|
||||||
|
|
||||||
class TestRPCSession:
|
|
||||||
@@ -765,21 +765,21 @@ 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)
|
|
||||||
+def msg_server_port(_function_event_loop, unused_tcp_port):
|
|
||||||
+ coro = serve_rs(MessageServer, 'localhost', unused_tcp_port, loop=_function_event_loop)
|
|
||||||
+ server = _function_event_loop.run_until_complete(coro)
|
|
||||||
yield unused_tcp_port
|
|
||||||
if hasattr(asyncio, 'all_tasks'):
|
|
||||||
- tasks = asyncio.all_tasks(event_loop)
|
|
||||||
+ tasks = asyncio.all_tasks(_function_event_loop)
|
|
||||||
else:
|
|
||||||
- tasks = asyncio.Task.all_tasks(loop=event_loop)
|
|
||||||
+ tasks = asyncio.Task.all_tasks(loop=_function_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())
|
|
||||||
+ _function_event_loop.run_until_complete(close_all())
|
|
||||||
|
|
||||||
|
|
||||||
def connect_message_session(host, port, proxy=None, framer=None):
|
|
||||||
--- a/tests/test_socks.py
|
|
||||||
+++ b/tests/test_socks.py
|
|
||||||
@@ -482,10 +482,10 @@ localhosts = ['127.0.0.1', '::1', 'local
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(params=localhosts)
|
|
||||||
-def proxy_address(request, event_loop, unused_tcp_port):
|
|
||||||
+def proxy_address(request, _function_event_loop, 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)
|
|
||||||
+ coro = _function_event_loop.create_server(FakeServer, host=host, port=unused_tcp_port)
|
|
||||||
+ server = _function_event_loop.run_until_complete(coro)
|
|
||||||
yield NetAddress(host, unused_tcp_port)
|
|
||||||
server.close()
|
|
||||||
|
|
||||||
--- a/tests/test_unixsocket.py
|
|
||||||
+++ b/tests/test_unixsocket.py
|
|
||||||
@@ -11,20 +11,20 @@ if sys.platform.startswith("win"):
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
-def us_server(event_loop):
|
|
||||||
+def us_server(_function_event_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)
|
|
||||||
+ coro = serve_us(MyServerSession, socket_path, loop=_function_event_loop)
|
|
||||||
+ server = _function_event_loop.run_until_complete(coro)
|
|
||||||
yield socket_path
|
|
||||||
- tasks = asyncio.all_tasks(event_loop)
|
|
||||||
+ tasks = asyncio.all_tasks(_function_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())
|
|
||||||
+ _function_event_loop.run_until_complete(close_all())
|
|
||||||
|
|
||||||
|
|
||||||
class TestUSTransport:
|
|
||||||
13
fix-jsonrpc-test-misc.patch
Normal file
13
fix-jsonrpc-test-misc.patch
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
Index: aiorpcX-0.25.0/tests/test_jsonrpc.py
|
||||||
|
===================================================================
|
||||||
|
--- aiorpcX-0.25.0.orig/tests/test_jsonrpc.py
|
||||||
|
+++ aiorpcX-0.25.0/tests/test_jsonrpc.py
|
||||||
|
@@ -1064,7 +1064,7 @@ async def test_max_response_size(protoco
|
||||||
|
await group.spawn(send_batch(batch))
|
||||||
|
|
||||||
|
|
||||||
|
-def test_misc(protocol):
|
||||||
|
+async def test_misc(protocol):
|
||||||
|
'''Misc tests to get full coverage.'''
|
||||||
|
connection = JSONRPCConnection(protocol)
|
||||||
|
|
||||||
@@ -1,3 +1,17 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Feb 4 12:44:25 UTC 2026 - Daniel Garcia <daniel.garcia@suse.com>
|
||||||
|
|
||||||
|
- Add fix-jsonrpc-test-misc.patch to fix broken tests
|
||||||
|
gh#kyuupichan/aiorpcX#56
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Jul 31 06:56:43 UTC 2025 - Jiri Slaby <jslaby@suse.cz>
|
||||||
|
|
||||||
|
- replace a non-upstream patch:
|
||||||
|
event_loop.patch
|
||||||
|
by an upstream one:
|
||||||
|
0001-Remove-event_loop-fixture-usage-from-tests.patch
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Tue Jul 29 07:18:50 UTC 2025 - Jiri Slaby <jslaby@suse.cz>
|
Tue Jul 29 07:18:50 UTC 2025 - Jiri Slaby <jslaby@suse.cz>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# spec file for package python-aiorpcX
|
# spec file for package python-aiorpcX
|
||||||
#
|
#
|
||||||
# Copyright (c) 2025 SUSE LLC
|
# Copyright (c) 2026 SUSE LLC and contributors
|
||||||
#
|
#
|
||||||
# All modifications and additions to the file contributed by third parties
|
# All modifications and additions to the file contributed by third parties
|
||||||
# remain the property of their copyright owners, unless otherwise agreed
|
# remain the property of their copyright owners, unless otherwise agreed
|
||||||
@@ -25,7 +25,9 @@ License: MIT
|
|||||||
Group: Development/Languages/Python
|
Group: Development/Languages/Python
|
||||||
URL: https://github.com/kyuupichan/aiorpcX
|
URL: https://github.com/kyuupichan/aiorpcX
|
||||||
Source: https://github.com/kyuupichan/aiorpcX/archive/%{version}.tar.gz
|
Source: https://github.com/kyuupichan/aiorpcX/archive/%{version}.tar.gz
|
||||||
Patch0: event_loop.patch
|
Patch0: 0001-Remove-event_loop-fixture-usage-from-tests.patch
|
||||||
|
# PATCH-FIX-OPENSUSE fix-jsonrpc-test-misc.patch -- gh#kyuupichan/aiorpcX#56
|
||||||
|
Patch1: fix-jsonrpc-test-misc.patch
|
||||||
BuildRequires: %{python_module pip}
|
BuildRequires: %{python_module pip}
|
||||||
BuildRequires: %{python_module setuptools}
|
BuildRequires: %{python_module setuptools}
|
||||||
BuildRequires: %{python_module wheel}
|
BuildRequires: %{python_module wheel}
|
||||||
@@ -48,10 +50,7 @@ BuildRequires: %{python_module websockets}
|
|||||||
Generic async RPC implementation, including JSON-RPC
|
Generic async RPC implementation, including JSON-RPC
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n aiorpcX-%{version}
|
%autosetup -p1 -n aiorpcX-%{version}
|
||||||
%if 0%{?suse_version} > 1600
|
|
||||||
%autopatch -p1
|
|
||||||
%endif
|
|
||||||
# needs network
|
# needs network
|
||||||
rm tests/test_websocket.py
|
rm tests/test_websocket.py
|
||||||
chmod a-x LICENCE README.rst docs/*
|
chmod a-x LICENCE README.rst docs/*
|
||||||
|
|||||||
Reference in New Issue
Block a user