Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_raise():
loop = asyncio.new_event_loop()
future = asyncio.Future(loop=loop)
@crontab('* * * * * *', start=False, loop=loop)
def t():
loop.call_later(1, future.set_result, 1)
raise ValueError()
t.start()
loop.run_until_complete(future)
t.stop()
assert future.result() == 1
def test_cron():
loop = asyncio.new_event_loop()
future = asyncio.Future(loop=loop)
@crontab('* * * * * *', start=False, loop=loop)
def t():
future.set_result(1)
t.start()
loop.run_until_complete(future)
t.stop()
assert future.result() == 1