8000 bpo-29679: Implement @contextlib.asynccontextmanager by JelleZijlstra · Pull Request #360 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-29679: Implement @contextlib.asynccontextmanager #360

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
May 1, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
combine duplicate tests
  • Loading branch information
JelleZijlstra committed Mar 2, 2017
commit 5808a4c987cab85103de034f230346130b1f6b74
30 changes: 9 additions & 21 deletions Lib/test/test_contextlib_async.py
4C51
Original file line number Diff line number Diff line change
Expand Up @@ -125,31 +125,19 @@ async def woohoo():

@_async_test
async def test_contextmanager_except_stopiter(self):
stop_exc = StopIteration('spam')
@asynccontextmanager
async def woohoo():
yield
try:
async with woohoo():
raise stop_exc
except Exception as ex:
self.assertIs(ex, stop_exc)
else:
self.fail('StopIteration was suppressed')

@_async_test
async def test_contextmanager_except_stopasynciter(self):
stop_exc = StopAsyncIteration('spam')
@asynccontextmanager
async def woohoo():
yield
try:
async with woohoo():
raise stop_exc
except Exception as ex:
self.assertIs(ex, stop_exc)
else:
self.fail('StopAsyncIteration was suppressed')
for stop_exc in (StopIteration('spam'), StopAsyncIteration('ham')):
with self.subTest(type=type(stop_exc)):
try:
async with woohoo():
raise stop_exc
except Exception as ex:
self.assertIs(ex, stop_exc)
else:
self.fail(f'{stop_exc} was suppressed')

def _create_contextmanager_attribs(self):
def attribs(**kw):
Expand Down
0