PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/tests/core/test_bridge.py

https://bitbucket.org/prologic/circuits/
Python | 41 lines | 21 code | 18 blank | 2 comment | 1 complexity | 7f85870c19f372170aaa0d8d915f7117 MD5 | raw file
 1#!/usr/bin/python -i
 2
 3
 4import pytest
 5
 6if pytest.PLATFORM == "win32":
 7    pytest.skip("Unsupported Platform")
 8
 9pytest.importorskip("multiprocessing")
10
11from os import getpid
12
13from circuits import Component, Event
14
15
16class hello(Event):
17    """hello Event"""
18
19
20class App(Component):
21
22    def hello(self):
23        return "Hello from {0:d}".format(getpid())
24
25
26def test(manager, watcher):
27    app = App()
28    process, bridge = app.start(process=True, link=manager)
29    assert watcher.wait("ready", timeout=30)
30
31    x = manager.fire(hello())
32
33    assert pytest.wait_for(x, "result")
34
35    assert x.value == "Hello from {0:d}".format(app.pid)
36
37    app.stop()
38    app.join()
39
40    bridge.unregister()
41    watcher.wait("unregistered")