def test_future_no_exc(self, fc, event_loop): """ If no exception is raised, the counter does not change. """ fut = asyncio.Future(loop=event_loop) coro = aio.count_exceptions(fc, future=fut) fut.set_result(42) assert 42 == (yield from coro) assert 0 == fc._val
async def test_future_no_exc(self, fc): """ If no exception is raised, the counter does not change. """ fut = asyncio.Future() coro = aio.count_exceptions(fc, future=fut) fut.set_result(42) assert 42 == await coro assert 0 == fc._val
def test_future_exc(self, fc, event_loop): """ If the correct exception is raised, count it. """ fut = asyncio.Future(loop=event_loop) coro = aio.count_exceptions(fc, exc=ValueError, future=fut) exc = ValueError() fut.set_exception(exc) with pytest.raises(Exception): assert 42 == (yield from coro) assert 1 == fc._val
def test_future_wrong_exc(self, fc, event_loop): """ If a wrong exception is raised, the counter does not change. """ fut = asyncio.Future(loop=event_loop) coro = aio.count_exceptions(fc, exc=ValueError, future=fut) exc = Exception() fut.set_exception(exc) with pytest.raises(Exception): assert 42 == (yield from coro) assert 0 == fc._val
async def test_future_exc(self, fc): """ If the correct exception is raised, count it. """ fut = asyncio.Future() coro = aio.count_exceptions(fc, exc=ValueError, future=fut) exc = ValueError() fut.set_exception(exc) with pytest.raises(Exception): assert 42 == await coro assert 1 == fc._val