相关疑难解决方法(0)

用nose测试python多处理池代码

我试图用鼻子编写测试,使用多处理计算得出的东西.

我有这个目录结构:

code/
    tests/
        tests.py
Run Code Online (Sandbox Code Playgroud)

tests.py看起来像这样:

import multiprocessing as mp


def f(i):
    return i ** 2


pool = mp.Pool()
out = pool.map(f, range(10))


def test_pool():
    """Really simple test that relies on the output of pool.map.
    The actual tests are much more complicated, but this is all
    that is needed to produce the problem."""
    ref_out = map(f, range(10))
    assert out == ref_out

if __name__ == '__main__':
    test_pool()
Run Code Online (Sandbox Code Playgroud)

从code目录运行,python tests/tests.py 传递.

nosetests tests/tests.py 未能完成.它启动,但永远不会通过呼叫pool.map …

python testing multiprocessing python-nose

6
推荐指数
1
解决办法
2529
查看次数

标签 统计

multiprocessing ×1

python ×1

python-nose ×1

testing ×1