<分区>
Possible Duplicate:
Can Python's unittest test in parallel, like nose can?
我有与 unittest 一起使用的测试,它们是 1 对 1 运行的。我想并行运行它们,因为我有很多等待,所以速度会快得多。 是否可以 ?尽管很多人都在谈论它,但我在互联网上找不到解决方案。
<分区>
Possible Duplicate:
Can Python's unittest test in parallel, like nose can?
我有与 unittest 一起使用的测试,它们是 1 对 1 运行的。我想并行运行它们,因为我有很多等待,所以速度会快得多。 是否可以 ?尽管很多人都在谈论它,但我在互联网上找不到解决方案。
最佳答案
您也可以通过 shell 进行并行化,不是吗?我刚试过这个命令
find -type f -name "_test_*.py" | sed 's/^\.\///; s/\.py$//; s/\//./g;' | xargs -t -P 10 -n 2 python -m unittest
find
输出测试文件列表,因此请根据您的命名约定调整文件名模式。 sed
将找到的路径转换为有效的模块名称。在此示例中,xargs
启动多达 10 个进程,每个进程运行 2 个测试模块。
我还不确定如何理解输出...
关于python - 并行单元测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8133453/