PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 5"""Pools Tests"""
 6
 7import pytest
 8
 9from circuits import Task, Pool
10
11
12def f():
13    x = 0
14    i = 0
15    while i < 1000000:
16        x += 1
17        i += 1
18    return x
19
20
21def test():
22    p = Pool()
23    p.start()
24
25    x = p.fire(Task(f))
26
27    assert pytest.wait_for(x, "result")
28
29    result = x.result
30    assert result
31
32    value = x.value
33    assert value == 1000000
34
35    p.stop()