blob: 2b4723a797bcc81e3b74c8f4d88a9d93397832f2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
import tests
try:
import asyncio
exec('''if 1:
def hello_world(result, delay):
result.append("Hello")
# retrieve the event loop from the policy
yield from asyncio.sleep(delay)
result.append('World')
''')
except ImportError:
import trollius as asyncio
from trollius import From
def hello_world(result, delay):
result.append("Hello")
# retrieve the event loop from the policy
yield From(asyncio.sleep(delay))
result.append('World')
class CallbackTests(tests.TestCase):
def test_hello_world(self):
result = []
self.loop.run_until_complete(hello_world(result, 0.001))
self.assertEqual(result, ['Hello', 'World'])
if __name__ == '__main__':
import unittest
unittest.main()
|