summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_asyncio')
-rw-r--r--Lib/test/test_asyncio/test_futures.py17
-rw-r--r--Lib/test/test_asyncio/test_locks.py5
-rw-r--r--Lib/test/test_asyncio/test_tasks.py6
3 files changed, 20 insertions, 8 deletions
diff --git a/Lib/test/test_asyncio/test_futures.py b/Lib/test/test_asyncio/test_futures.py
index 50e9414..e5002bc 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'
diff --git a/Lib/test/test_asyncio/test_locks.py b/Lib/test/test_asyncio/test_locks.py
index c4e74e3..dda4577 100644
--- a/Lib/test/test_asyncio/test_locks.py
+++ b/Lib/test/test_asyncio/test_locks.py
@@ -660,10 +660,13 @@ class ConditionTests(test_utils.TestCase):
lock = asyncio.Lock(loop=self.loop)
cond = asyncio.Condition(lock, loop=self.loop)
- self.assertIs(lock._loop, cond._loop)
+ self.assertIs(cond._lock, lock)
+ self.assertIs(cond._loop, lock._loop)
def test_ambiguous_loops(self):
loop = self.new_test_loop()
+ self.addCleanup(loop.close)
+
lock = asyncio.Lock(loop=self.loop)
with self.assertRaises(ValueError):
asyncio.Condition(lock, loop=loop)
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py
index 7b93a0e..95cba54 100644
--- a/Lib/test/test_asyncio/test_tasks.py
+++ b/Lib/test/test_asyncio/test_tasks.py
@@ -132,6 +132,8 @@ class TaskTests(test_utils.TestCase):
asyncio.async('ok')
def test_task_repr(self):
+ self.loop.set_debug(False)
+
@asyncio.coroutine
def notmuch():
yield from []
@@ -189,6 +191,8 @@ class TaskTests(test_utils.TestCase):
"<Task finished %s result='abc'>" % coro)
def test_task_repr_coro_decorator(self):
+ self.loop.set_debug(False)
+
@asyncio.coroutine
def notmuch():
# notmuch() function doesn't use yield from: it will be wrapped by
@@ -252,6 +256,8 @@ class TaskTests(test_utils.TestCase):
self.loop.run_until_complete(t)
def test_task_repr_wait_for(self):
+ self.loop.set_debug(False)
+
@asyncio.coroutine
def wait_for(fut):
return (yield from fut)