[Python-checkins] cpython (merge 3.5 -> default): Merge 3.5 (Issue #24692)
yury.selivanov
python-checkins at python.org
Thu Jul 23 14:59:31 CEST 2015
https://hg.python.org/cpython/rev/3f3e398bcd3e
changeset: 97020:3f3e398bcd3e
parent: 97018:3f8048926690
parent: 97019:636ce05ea8f6
user: Yury Selivanov <yselivanov at sprymix.com>
date: Thu Jul 23 15:58:57 2015 +0300
summary:
Merge 3.5 (Issue #24692)
files:
Lib/test/test_types.py | 24 +++++++++++++++++++-----
1 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py
--- a/Lib/test/test_types.py
+++ b/Lib/test/test_types.py
@@ -1213,6 +1213,10 @@
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 @@
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 @@
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 @@
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)
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list