Blob Blame History Raw
From 71189b2c1d7f3df11959eefe921bee34444d071f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hrn=C4=8Diar?= <thrnciar@redhat.com>
Date: Wed, 29 Jun 2022 08:56:05 +0200
Subject: [PATCH] Fix test failures on Python 3.11 due to asyncio.coroutine
 being removed

Fixes: #180
---
 test/test_as_future.py  | 5 +----
 test/test_call_later.py | 7 ++-----
 test/test_is_future.py  | 6 ++----
 3 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/test/test_as_future.py b/test/test_as_future.py
index aadc20c..af2d8f5 100644
--- a/test/test_as_future.py
+++ b/test/test_as_future.py
@@ -102,10 +102,7 @@ def test_as_future_coroutine(framework):
     results = []
     calls = []
 
-    from asyncio import coroutine
-
-    @coroutine
-    def method(*args, **kw):
+    async def method(*args, **kw):
         calls.append((args, kw))
         return 42
     f = txaio.as_future(method, 1, 2, 3, key='word')
diff --git a/test/test_call_later.py b/test/test_call_later.py
index 5f8e70f..19a27c2 100644
--- a/test/test_call_later.py
+++ b/test/test_call_later.py
@@ -171,11 +171,8 @@ def test_explicit_reactor_coroutine(framework):
     if txaio.using_twisted:
         pytest.skip()
 
-    from asyncio import coroutine
-
-    @coroutine
-    def some_coroutine():
-        yield 'nothing'
+    async def some_coroutine():
+        await 'nothing'
 
     with patch.object(txaio.config, 'loop') as fake_loop:
         txaio.as_future(some_coroutine)
diff --git a/test/test_is_future.py b/test/test_is_future.py
index fcadc7f..af2ce75 100644
--- a/test/test_is_future.py
+++ b/test/test_is_future.py
@@ -42,11 +42,9 @@ def test_is_future_coroutine(framework_aio):
     Returning an immediate value from as_future
     '''
     pytest.importorskip('asyncio')  # 'aio' might be using trollius
-    from asyncio import coroutine
 
-    @coroutine
-    def some_coroutine():
-        yield 'answer'
+    async def some_coroutine():
+        await 'answer'
     obj = some_coroutine()
     assert txaio.is_future(obj)