summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_tasks.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-06-16 15:11:05 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-06-16 15:11:05 (GMT)
commit4802c6ee55f2721776cc9d05b1422dab85f244ce (patch)
treec28776ed1a3d70edcdc34fc4f9fdbdf7f96b06b2 /Lib/test/test_asyncio/test_tasks.py
parent5b1fdc1e377df88078f7788bf85dfebd353dc178 (diff)
downloadcpython-4802c6ee55f2721776cc9d05b1422dab85f244ce.zip
cpython-4802c6ee55f2721776cc9d05b1422dab85f244ce.tar.gz
cpython-4802c6ee55f2721776cc9d05b1422dab85f244ce.tar.bz2
Sync asyncio with Tulip: Fix test_tasks for Python 3.5
On Python 3.5, generator now gets their name from the function, no more from the code. So we get the expected "notmuch" name instead of the generic "coro" name.
Diffstat (limited to 'Lib/test/test_asyncio/test_tasks.py')
-rw-r--r--Lib/test/test_asyncio/test_tasks.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py
index 92eb9da..4e239ec 100644
--- a/Lib/test/test_asyncio/test_tasks.py
+++ b/Lib/test/test_asyncio/test_tasks.py
@@ -2,6 +2,7 @@
import gc
import os.path
+import sys
import types
import unittest
import weakref
@@ -154,10 +155,13 @@ class TaskTests(unittest.TestCase):
t = MyTask(gen, loop=self.loop)
filename = gen.gi_code.co_filename
lineno = gen.gi_frame.f_lineno
- # FIXME: check for the name "coro" instead of "notmuch" because
- # @asyncio.coroutine drops the name of the wrapped function:
- # http://bugs.python.org/issue21205
- self.assertEqual(repr(t), 'T[](<coro at %s:%s>)' % (filename, lineno))
+ if sys.version_info >= (3, 5):
+ name = 'notmuch'
+ else:
+ # On Python < 3.5, generators inherit the name of the code, not of
+ # the function. See: http://bugs.python.org/issue21205
+ name = 'coro'
+ self.assertEqual(repr(t), 'T[](<%s at %s:%s>)' % (name, filename, lineno))
def test_task_basics(self):
@asyncio.coroutine