aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_asyncio/test_futures.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-07-29 12:58:23 +0200
committerVictor Stinner <victor.stinner@gmail.com>2014-07-29 12:58:23 +0200
commit313a9809043ed2ed1ad25282af7169e08cdc92a3 (patch)
tree99a23db8538b3dcafb55fb1b83c838a992c969fb /Lib/test/test_asyncio/test_futures.py
parent7eca7343a0a01ead026589d4e3828bbdee9d08a0 (diff)
downloadcpython-313a9809043ed2ed1ad25282af7169e08cdc92a3.tar.gz
cpython-313a9809043ed2ed1ad25282af7169e08cdc92a3.zip
asyncio: sync with Tulip
* _WaitHandleFuture.cancel() now notify IocpProactor through the overlapped object that the wait was cancelled. * Optimize IocpProactor.wait_for_handle() gets the result if the wait is signaled immediatly. * Enhance representation of Future and Future subclasses - Add "created at filename:lineno" in the representation - Add Future._repr_info() method which can be more easily overriden than Future.__repr__(). It should now be more easy to enhance Future representation without having to modify each subclass. For example, _OverlappedFuture and _WaitHandleFuture get the new "created at" information. - Use reprlib to format Future result, and function arguments when formatting a callback, to limit the length of the representation. * Fix repr(_WaitHandleFuture) * _WaitHandleFuture and _OverlappedFuture: hide frames of internal calls in the source traceback. * Cleanup ProactorIocp._poll(): set the timeout to 0 after the first call to GetQueuedCompletionStatus() * test_locks: close the temporary event loop and check the condition lock * Remove workaround in test_futures, no more needed
Diffstat (limited to 'Lib/test/test_asyncio/test_futures.py')
-rw-r--r--Lib/test/test_asyncio/test_futures.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/Lib/test/test_asyncio/test_futures.py b/Lib/test/test_asyncio/test_futures.py
index 50e9414ab8f..e5002bc825d 100644
--- a/Lib/test/test_asyncio/test_futures.py
+++ b/Lib/test/test_asyncio/test_futures.py
@@ -105,6 +105,15 @@ class FutureTests(test_utils.TestCase):
self.assertEqual(next(g), ('C', 42)) # yield 'C', y.
def test_future_repr(self):
+ self.loop.set_debug(True)
+ f_pending_debug = asyncio.Future(loop=self.loop)
+ frame = f_pending_debug._source_traceback[-1]
+ self.assertEqual(repr(f_pending_debug),
+ '<Future pending created at %s:%s>'
+ % (frame[0], frame[1]))
+ f_pending_debug.cancel()
+
+ self.loop.set_debug(False)
f_pending = asyncio.Future(loop=self.loop)
self.assertEqual(repr(f_pending), '<Future pending>')
f_pending.cancel()
@@ -299,12 +308,6 @@ class FutureTests(test_utils.TestCase):
@mock.patch('asyncio.base_events.logger')
def test_future_exception_never_retrieved(self, m_log):
- # FIXME: Python issue #21163, other tests may "leak" pending task which
- # emit a warning when they are destroyed by the GC
- support.gc_collect()
- m_log.error.reset_mock()
- # ---
-
self.loop.set_debug(True)
def memory_error():
@@ -324,7 +327,7 @@ class FutureTests(test_utils.TestCase):
if sys.version_info >= (3, 4):
frame = source_traceback[-1]
regex = (r'^Future exception was never retrieved\n'
- r'future: <Future finished exception=MemoryError\(\)>\n'
+ r'future: <Future finished exception=MemoryError\(\) created at {filename}:{lineno}>\n'
r'source_traceback: Object created at \(most recent call last\):\n'
r' File'
r'.*\n'