Skip to content

Commit

Permalink
COVERAGE FOR THE COVERAGE GOD
Browse files Browse the repository at this point in the history
  • Loading branch information
njsmith committed Jan 19, 2018
1 parent d014a52 commit 4b740df
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions async_generator/_tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ async def noop_async_context_manager():
async with noop_async_context_manager():
raise exc_type

# And let's also check a boring nothing pass-through while we're at it
async with noop_async_context_manager():
pass


async def test_asynccontextmanager_catches_exception():
@asynccontextmanager
Expand All @@ -139,6 +143,33 @@ async def catch_it():
raise ValueError


async def test_asynccontextmanager_different_exception():
@asynccontextmanager
@async_generator
async def switch_it():
try:
await yield_()
except KeyError:
raise ValueError

with pytest.raises(ValueError):
async with switch_it():
raise KeyError


def test_asynccontextmanager_nice_message_on_sync_enter():
@asynccontextmanager
@async_generator
async def xxx(): # pragma: no cover
pass

with pytest.raises(RuntimeError) as excinfo:
with xxx():
pass # pragma: no cover

assert "async with" in str(excinfo.value)


async def test_asynccontextmanager_no_yield():
@asynccontextmanager
@async_generator
Expand Down

0 comments on commit 4b740df

Please sign in to comment.