summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_pep492.py
diff options
context:
space:
mode:
authorAndrew Svetlov <andrew.svetlov@gmail.com>2017-12-09 18:00:05 (GMT)
committerGitHub <noreply@github.com>2017-12-09 18:00:05 (GMT)
commit28d8d14013ade0657fed4673f5fa3c08eb2b1944 (patch)
tree4c24b73040f8f13eafd9216c934f2d27218e91d8 /Lib/test/test_asyncio/test_pep492.py
parenta9f8df646aac7fc94ced0aefd1ed2c8566d14d10 (diff)
downloadcpython-28d8d14013ade0657fed4673f5fa3c08eb2b1944.zip
cpython-28d8d14013ade0657fed4673f5fa3c08eb2b1944.tar.gz
cpython-28d8d14013ade0657fed4673f5fa3c08eb2b1944.tar.bz2
bpo-32253: Deprecate with statement and bare await for asyncio locks (GH-4764)
* Add test for 'with (yield from lock)' * Deprecate with statement for asyncio locks * Document the deprecation
Diffstat (limited to 'Lib/test/test_asyncio/test_pep492.py')
-rw-r--r--Lib/test/test_asyncio/test_pep492.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/Lib/test/test_asyncio/test_pep492.py b/Lib/test/test_asyncio/test_pep492.py
index 77eb7cd..4425770 100644
--- a/Lib/test/test_asyncio/test_pep492.py
+++ b/Lib/test/test_asyncio/test_pep492.py
@@ -59,12 +59,13 @@ class LockTests(BaseTest):
async def test(lock):
await asyncio.sleep(0.01, loop=self.loop)
self.assertFalse(lock.locked())
- with await lock as _lock:
- self.assertIs(_lock, None)
- self.assertTrue(lock.locked())
- await asyncio.sleep(0.01, loop=self.loop)
- self.assertTrue(lock.locked())
- self.assertFalse(lock.locked())
+ with self.assertWarns(DeprecationWarning):
+ with await lock as _lock:
+ self.assertIs(_lock, None)
+ self.assertTrue(lock.locked())
+ await asyncio.sleep(0.01, loop=self.loop)
+ self.assertTrue(lock.locked())
+ self.assertFalse(lock.locked())
for primitive in primitives:
self.loop.run_until_complete(test(primitive))