[Python-checkins] cpython (3.4): asyncio: IocpProactor.wait_for_handle() test now also checks the result of the

victor.stinner python-checkins at python.org
Fri Dec 19 17:11:50 CET 2014


https://hg.python.org/cpython/rev/13f206394380
changeset:   93928:13f206394380
branch:      3.4
parent:      93926:c2bc0da1d1f9
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Fri Dec 19 17:10:44 2014 +0100
summary:
  asyncio: IocpProactor.wait_for_handle() test now also checks the result of the
future

files:
  Lib/asyncio/windows_events.py                |  5 +++++
  Lib/test/test_asyncio/test_windows_events.py |  8 ++++++--
  2 files changed, 11 insertions(+), 2 deletions(-)


diff --git a/Lib/asyncio/windows_events.py b/Lib/asyncio/windows_events.py
--- a/Lib/asyncio/windows_events.py
+++ b/Lib/asyncio/windows_events.py
@@ -427,6 +427,11 @@
         return self._register(ov, None, finish_connect_pipe, wait_for_post=True)
 
     def wait_for_handle(self, handle, timeout=None):
+        """Wait for a handle.
+
+        Return a Future object. The result of the future is True if the wait
+        completed, or False if the wait did not complete (on timeout).
+        """
         if timeout is None:
             ms = _winapi.INFINITE
         else:
diff --git a/Lib/test/test_asyncio/test_windows_events.py b/Lib/test/test_asyncio/test_windows_events.py
--- a/Lib/test/test_asyncio/test_windows_events.py
+++ b/Lib/test/test_asyncio/test_windows_events.py
@@ -98,8 +98,10 @@
         # result should be False at timeout
         fut = self.loop._proactor.wait_for_handle(event, 0.5)
         start = self.loop.time()
-        self.loop.run_until_complete(fut)
+        done = self.loop.run_until_complete(fut)
         elapsed = self.loop.time() - start
+
+        self.assertEqual(done, False)
         self.assertFalse(fut.result())
         self.assertTrue(0.48 < elapsed < 0.9, elapsed)
 
@@ -109,8 +111,10 @@
         # result should be True immediately
         fut = self.loop._proactor.wait_for_handle(event, 10)
         start = self.loop.time()
-        self.loop.run_until_complete(fut)
+        done = self.loop.run_until_complete(fut)
         elapsed = self.loop.time() - start
+
+        self.assertEqual(done, True)
         self.assertTrue(fut.result())
         self.assertTrue(0 <= elapsed < 0.3, elapsed)
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list