/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. import pytest
  3. if pytest.PLATFORM == "win32":
  4. pytest.skip("Unsupported Platform")
  5. pytest.importorskip("multiprocessing")
  6. from os import getpid
  7. from circuits import Component, Event
  8. class hello(Event):
  9. """hello Event"""
  10. class App(Component):
  11. def hello(self):
  12. return "Hello from {0:d}".format(getpid())
  13. def test(manager, watcher):
  14. app = App()
  15. process, bridge = app.start(process=True, link=manager)
  16. assert watcher.wait("ready", timeout=30)
  17. x = manager.fire(hello())
  18. assert pytest.wait_for(x, "result")
  19. assert x.value == "Hello from {0:d}".format(app.pid)
  20. app.stop()
  21. app.join()
  22. bridge.unregister()
  23. watcher.wait("unregistered")