/tests/core/test_pools.py

https://bitbucket.org/prologic/circuits/ · Python · 35 lines · 19 code · 12 blank · 4 comment · 1 complexity · 5bf01046205ebfabb543c9d7ef200fe0 MD5 · raw file

  1. # Module: test_pools
  2. # Date: 22nd February 2011
  3. # Author: James Mills, prologic at shortcircuit dot net dot au
  4. """Pools Tests"""
  5. import pytest
  6. from circuits import Task, Pool
  7. def f():
  8. x = 0
  9. i = 0
  10. while i < 1000000:
  11. x += 1
  12. i += 1
  13. return x
  14. def test():
  15. p = Pool()
  16. p.start()
  17. x = p.fire(Task(f))
  18. assert pytest.wait_for(x, "result")
  19. result = x.result
  20. assert result
  21. value = x.value
  22. assert value == 1000000
  23. p.stop()