blob: 987960bdc9b0ca44154d7a06c8c44f683e2e8d75 (
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
33
34
|
import eventlet
import tests
class CallbackTests(tests.TestCase):
def test_hello_world(self):
result = []
def hello_world(loop):
result.append('Hello World')
loop.stop()
self.loop.call_soon(hello_world, self.loop)
self.loop.run_forever()
self.assertEqual(result, ['Hello World'])
def test_soon_stop_soon(self):
result = []
def hello():
result.append("Hello")
def world():
result.append("World")
self.loop.stop()
self.loop.call_soon(hello)
self.loop.call_soon(self.loop.stop)
self.loop.call_soon(world)
self.loop.run_forever()
self.assertEqual(result, ["Hello"])
self.loop.run_forever()
self.assertEqual(result, ["Hello", "World"])
|