summaryrefslogtreecommitdiff
path: root/Lib/test/test_asyncio/test_locks.py
diff options
context:
space:
mode:
authorIllia Volochii <illia.volochii@gmail.com>2021-07-01 16:13:59 +0300
committerGitHub <noreply@github.com>2021-07-01 15:13:59 +0200
commita1092f62492a3fcd6195bea94eccf8d5a300acb1 (patch)
treee6771f532ecc51ff4665e0f4dd6d715c31b0c04d /Lib/test/test_asyncio/test_locks.py
parent3623aaa78cb9c50edb6da5ac37000446f138b91c (diff)
downloadcpython-git-a1092f62492a3fcd6195bea94eccf8d5a300acb1.tar.gz
bpo-43216: Remove @asyncio.coroutine (GH-26369)
Remove the @asyncio.coroutine decorator enabling legacy generator-based coroutines to be compatible with async/await code; remove asyncio.coroutines.CoroWrapper used for wrapping legacy coroutine objects in the debug mode. The decorator has been deprecated since Python 3.8 and the removal was initially scheduled for Python 3.10.
Diffstat (limited to 'Lib/test/test_asyncio/test_locks.py')
-rw-r--r--Lib/test/test_asyncio/test_locks.py38
1 files changed, 16 insertions, 22 deletions
diff --git a/Lib/test/test_asyncio/test_locks.py b/Lib/test/test_asyncio/test_locks.py
index 6194cd0617..441adeea8f 100644
--- a/Lib/test/test_asyncio/test_locks.py
+++ b/Lib/test/test_asyncio/test_locks.py
@@ -38,14 +38,12 @@ class LockTests(test_utils.TestCase):
def test_lock(self):
lock = asyncio.Lock()
- with self.assertWarns(DeprecationWarning):
- @asyncio.coroutine
- def acquire_lock():
- return (yield from lock)
+ async def acquire_lock():
+ return await lock
with self.assertRaisesRegex(
TypeError,
- "object is not iterable"
+ "object Lock can't be used in 'await' expression"
):
self.loop.run_until_complete(acquire_lock())
@@ -78,18 +76,16 @@ class LockTests(test_utils.TestCase):
asyncio.BoundedSemaphore(),
]
- with self.assertWarns(DeprecationWarning):
- @asyncio.coroutine
- def test(lock):
- yield from asyncio.sleep(0.01)
- self.assertFalse(lock.locked())
- with self.assertRaisesRegex(
- TypeError,
- "object is not iterable"
- ):
- with (yield from lock):
- pass
- self.assertFalse(lock.locked())
+ async def test(lock):
+ await asyncio.sleep(0.01)
+ self.assertFalse(lock.locked())
+ with self.assertRaisesRegex(
+ TypeError,
+ r"object \w+ can't be used in 'await' expression"
+ ):
+ with await lock:
+ pass
+ self.assertFalse(lock.locked())
for primitive in primitives:
loop.run_until_complete(test(primitive))
@@ -788,14 +784,12 @@ class SemaphoreTests(test_utils.TestCase):
sem = asyncio.Semaphore()
self.assertEqual(1, sem._value)
- with self.assertWarns(DeprecationWarning):
- @asyncio.coroutine
- def acquire_lock():
- return (yield from sem)
+ async def acquire_lock():
+ return await sem
with self.assertRaisesRegex(
TypeError,
- "'Semaphore' object is not iterable",
+ "object Semaphore can't be used in 'await' expression",
):
self.loop.run_until_complete(acquire_lock())