Folly Futures to Python Asyncio Futures Bridge
[folly.git] / folly / python / test / futures.py
1 #!/usr/bin/env python3
2 import asyncio
3 import unittest
4
5 from . import simplebridge
6
7
8 class Futures(unittest.TestCase):
9     def test_bridge(self):
10         val = 1337
11         loop = asyncio.get_event_loop()
12         res = loop.run_until_complete(simplebridge.get_value_x5(val))
13         self.assertEqual(val * 5, res)
14
15     def test_bridge_exception(self):
16         loop = asyncio.get_event_loop()
17         with self.assertRaises(ValueError, msg="0 is not allowed"):
18             loop.run_until_complete(simplebridge.get_value_x5(0))