Fix Python 3.11 test failures
This commit is contained in:
parent
7d6390c9c5
commit
b2a21c29f2
61
1176.patch
Normal file
61
1176.patch
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
From ab4b20f6cbf4f04bd8e38a6885906d5afc9bb435 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
|
||||||
|
Date: Sun, 15 May 2022 10:27:09 +0200
|
||||||
|
Subject: [PATCH 1/2] Wrap recv_into() in test_explicit_socket to fix py3.11
|
||||||
|
|
||||||
|
Extend TrackedSocket class in test_explicit_socket to wrap
|
||||||
|
the recv_into() method. The Python 3.11 implementation of asyncio
|
||||||
|
is calling it rather than recv(), therefore causing used_for_read
|
||||||
|
not to be set if it's not wrapped.
|
||||||
|
---
|
||||||
|
tests/legacy/test_client_server.py | 6 +++++-
|
||||||
|
1 file changed, 5 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/tests/legacy/test_client_server.py b/tests/legacy/test_client_server.py
|
||||||
|
index f9de70c9..b627644b 100644
|
||||||
|
--- a/tests/legacy/test_client_server.py
|
||||||
|
+++ b/tests/legacy/test_client_server.py
|
||||||
|
@@ -422,10 +422,14 @@ def __init__(self, *args, **kwargs):
|
||||||
|
self.used_for_write = False
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
- def recv(self, *args, **kwargs):
|
||||||
|
+ def recv(self, *args, **kwargs): # pragma: no cover
|
||||||
|
self.used_for_read = True
|
||||||
|
return super().recv(*args, **kwargs)
|
||||||
|
|
||||||
|
+ def recv_into(self, *args, **kwargs): # pragma: no cover
|
||||||
|
+ self.used_for_read = True
|
||||||
|
+ return super().recv_into(*args, **kwargs)
|
||||||
|
+
|
||||||
|
def send(self, *args, **kwargs):
|
||||||
|
self.used_for_write = True
|
||||||
|
return super().send(*args, **kwargs)
|
||||||
|
|
||||||
|
From 008ea57bb216b2c8ac0c50a4332c7d24ee3f889b Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
|
||||||
|
Date: Sun, 15 May 2022 10:32:03 +0200
|
||||||
|
Subject: [PATCH 2/2] Skip YieldFromTests in Python 3.11+
|
||||||
|
|
||||||
|
asyncio.coroutine has been removed in Python 3.11, so skip it if Python
|
||||||
|
is newer than that.
|
||||||
|
|
||||||
|
Fixes #1175
|
||||||
|
---
|
||||||
|
tests/legacy/test_client_server.py | 3 +++
|
||||||
|
1 file changed, 3 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/tests/legacy/test_client_server.py b/tests/legacy/test_client_server.py
|
||||||
|
index b627644b..bf5d2f39 100644
|
||||||
|
--- a/tests/legacy/test_client_server.py
|
||||||
|
+++ b/tests/legacy/test_client_server.py
|
||||||
|
@@ -1303,6 +1303,9 @@ def test_checking_lack_of_origin_succeeds_backwards_compatibility(self):
|
||||||
|
self.assertEqual(self.loop.run_until_complete(self.client.recv()), "Hello!")
|
||||||
|
|
||||||
|
|
||||||
|
+@unittest.skipIf(
|
||||||
|
+ sys.version_info[:2] >= (3, 11), "asyncio.coroutine has been removed in Python 3.11"
|
||||||
|
+)
|
||||||
|
class YieldFromTests(ClientServerTestsMixin, AsyncioTestCase):
|
||||||
|
@with_server()
|
||||||
|
def test_client(self):
|
@ -13,6 +13,9 @@ License: BSD
|
|||||||
URL: https://github.com/aaugustin/websockets
|
URL: https://github.com/aaugustin/websockets
|
||||||
Source0: %{url}/archive/%{version}/%{pypi_name}-%{version}.tar.gz
|
Source0: %{url}/archive/%{version}/%{pypi_name}-%{version}.tar.gz
|
||||||
|
|
||||||
|
# Fix Python 3.11 test failures
|
||||||
|
Patch: https://github.com/aaugustin/websockets/pull/1176.patch
|
||||||
|
|
||||||
BuildRequires: gcc
|
BuildRequires: gcc
|
||||||
|
|
||||||
%global _description %{expand:
|
%global _description %{expand:
|
||||||
|
Loading…
Reference in New Issue
Block a user