summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorAndrew Svetlov <andrew.svetlov@gmail.com>2019-09-11 13:40:36 +0300
committerGitHub <noreply@github.com>2019-09-11 13:40:36 +0300
commit4601f7a49fe8ed00c4b6b70b0eda2b3922568e9b (patch)
tree4a52abadaf3d6be61df7a17de12cb90e1de4b941 /Lib
parent80db4b4be54ccdb5b67821506b6db2b27bd7c28a (diff)
downloadcpython-git-4601f7a49fe8ed00c4b6b70b0eda2b3922568e9b.tar.gz
[3.8] bpo-36373: Fix deprecation warnings (GH-15889) (GH-15901)
https://bugs.python.org/issue36373 (cherry picked from commit 7264e92b718d307cc499b2f10eab7644b00f0499) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
Diffstat (limited to 'Lib')
-rw-r--r--Lib/asyncio/locks.py2
-rw-r--r--Lib/asyncio/queues.py2
-rw-r--r--Lib/test/test_asyncio/test_locks.py7
-rw-r--r--Lib/test/test_asyncio/test_queues.py3
-rw-r--r--Lib/unittest/async_case.py10
5 files changed, 12 insertions, 12 deletions
diff --git a/Lib/asyncio/locks.py b/Lib/asyncio/locks.py
index f63d4cedbb..d94daeb5a1 100644
--- a/Lib/asyncio/locks.py
+++ b/Lib/asyncio/locks.py
@@ -332,7 +332,7 @@ class Condition(_ContextManagerMixin):
DeprecationWarning, stacklevel=2)
if lock is None:
- lock = Lock(loop=self._loop)
+ lock = Lock(loop=loop)
elif lock._loop is not self._loop:
raise ValueError("loop argument must agree with lock")
diff --git a/Lib/asyncio/queues.py b/Lib/asyncio/queues.py
index c96b4a0c1b..390ae9a682 100644
--- a/Lib/asyncio/queues.py
+++ b/Lib/asyncio/queues.py
@@ -45,7 +45,7 @@ class Queue:
# Futures.
self._putters = collections.deque()
self._unfinished_tasks = 0
- self._finished = locks.Event(loop=self._loop)
+ self._finished = locks.Event(loop=loop)
self._finished.set()
self._init(maxsize)
diff --git a/Lib/test/test_asyncio/test_locks.py b/Lib/test/test_asyncio/test_locks.py
index d69b56dcda..a9953b4b2a 100644
--- a/Lib/test/test_asyncio/test_locks.py
+++ b/Lib/test/test_asyncio/test_locks.py
@@ -500,10 +500,9 @@ class ConditionTests(test_utils.TestCase):
self.assertIs(cond._loop, self.loop)
def test_ctor_noloop(self):
- with self.assertWarns(DeprecationWarning):
- asyncio.set_event_loop(self.loop)
- cond = asyncio.Condition()
- self.assertIs(cond._loop, self.loop)
+ asyncio.set_event_loop(self.loop)
+ cond = asyncio.Condition()
+ self.assertIs(cond._loop, self.loop)
def test_wait(self):
with self.assertWarns(DeprecationWarning):
diff --git a/Lib/test/test_asyncio/test_queues.py b/Lib/test/test_asyncio/test_queues.py
index 02e8e43cce..171176c9fc 100644
--- a/Lib/test/test_asyncio/test_queues.py
+++ b/Lib/test/test_asyncio/test_queues.py
@@ -83,8 +83,7 @@ class QueueBasicTests(_QueueTestBase):
def test_ctor_noloop(self):
asyncio.set_event_loop(self.loop)
- with self.assertWarns(DeprecationWarning):
- q = asyncio.Queue()
+ q = asyncio.Queue()
self.assertIs(q._loop, self.loop)
def test_repr(self):
diff --git a/Lib/unittest/async_case.py b/Lib/unittest/async_case.py
index a3c8bfb9ec..1bc1312c8c 100644
--- a/Lib/unittest/async_case.py
+++ b/Lib/unittest/async_case.py
@@ -89,8 +89,9 @@ class IsolatedAsyncioTestCase(TestCase):
else:
return ret
- async def _asyncioLoopRunner(self):
- queue = self._asyncioCallsQueue
+ async def _asyncioLoopRunner(self, fut):
+ self._asyncioCallsQueue = queue = asyncio.Queue()
+ fut.set_result(None)
while True:
query = await queue.get()
queue.task_done()
@@ -113,8 +114,9 @@ class IsolatedAsyncioTestCase(TestCase):
asyncio.set_event_loop(loop)
loop.set_debug(True)
self._asyncioTestLoop = loop
- self._asyncioCallsQueue = asyncio.Queue(loop=loop)
- self._asyncioCallsTask = loop.create_task(self._asyncioLoopRunner())
+ fut = loop.create_future()
+ self._asyncioCallsTask = loop.create_task(self._asyncioLoopRunner(fut))
+ loop.run_until_complete(fut)
def _tearDownAsyncioLoop(self):
assert self._asyncioTestLoop is not None