summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2015-07-23 12:58:57 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2015-07-23 12:58:57 (GMT)
commit56786c9ea27efb30320f89d663dbff74f5a5e014 (patch)
tree708f517efef2a4430adb8efecfda57fb4670a3e4 /Lib
parent38d3876bfbeef65ec8ddc81cd88c739e6e8c3699 (diff)
parent4887523c038bc3449fe87a10828355e624de6565 (diff)
downloadcpython-56786c9ea27efb30320f89d663dbff74f5a5e014.zip
cpython-56786c9ea27efb30320f89d663dbff74f5a5e014.tar.gz
cpython-56786c9ea27efb30320f89d663dbff74f5a5e014.tar.bz2
Merge 3.5 (Issue #24692)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_types.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py
index 738588e..5e74115 100644
--- a/Lib/test/test_types.py
+++ b/Lib/test/test_types.py
@@ -1213,6 +1213,10 @@ class CoroutineTests(unittest.TestCase):
return aw
self.assertIs(aw, foo())
+ # decorate foo second time
+ foo = types.coroutine(foo)
+ self.assertIs(aw, foo())
+
def test_async_def(self):
# Test that types.coroutine passes 'async def' coroutines
# without modification
@@ -1226,12 +1230,13 @@ class CoroutineTests(unittest.TestCase):
self.assertIs(decorated_foo.__code__, foo_code)
foo_coro = foo()
- @types.coroutine
def bar(): return foo_coro
- coro = bar()
- self.assertIs(foo_coro, coro)
- self.assertEqual(coro.cr_code.co_flags, foo_flags)
- coro.close()
+ for _ in range(2):
+ bar = types.coroutine(bar)
+ coro = bar()
+ self.assertIs(foo_coro, coro)
+ self.assertEqual(coro.cr_code.co_flags, foo_flags)
+ coro.close()
def test_duck_coro(self):
class CoroLike:
@@ -1447,6 +1452,10 @@ class CoroutineTests(unittest.TestCase):
with self.assertRaisesRegex(Exception, 'ham'):
wrapper.throw(Exception, Exception('ham'))
+ # decorate foo second time
+ foo = types.coroutine(foo)
+ self.assertIs(foo().__await__(), gen)
+
def test_returning_itercoro(self):
@types.coroutine
def gen():
@@ -1460,9 +1469,14 @@ class CoroutineTests(unittest.TestCase):
self.assertIs(foo(), gencoro)
+ # decorate foo second time
+ foo = types.coroutine(foo)
+ self.assertIs(foo(), gencoro)
+
def test_genfunc(self):
def gen(): yield
self.assertIs(types.coroutine(gen), gen)
+ self.assertIs(types.coroutine(types.coroutine(gen)), gen)
self.assertTrue(gen.__code__.co_flags & inspect.CO_ITERABLE_COROUTINE)
self.assertFalse(gen.__code__.co_flags & inspect.CO_COROUTINE)