Add loop helpers and simplify deploy example
[osm/N2VC.git] / tests / test_loop.py
1 import unittest
2 import juju.loop
3
4
5 class TestLoop(unittest.TestCase):
6 def test_run(self):
7 async def _test():
8 return 'success'
9 self.assertEqual(juju.loop.run(_test()), 'success')
10
11 def test_run_interrupt(self):
12 async def _test():
13 juju.loop.run._sigint = True
14 self.assertRaises(KeyboardInterrupt, juju.loop.run, _test())
15
16 def test_run_exception(self):
17 async def _test():
18 raise ValueError()
19 self.assertRaises(ValueError, juju.loop.run, _test())