Is it possible to use Nose to run one test multiple times, concurrently?

时光怂恿深爱的人放手 提交于 2019-12-03 12:01:50

It is possible to run tests concurrently with nose:

Using the nose.plugin.multiprocess plugin, you can parallelize a test run across a configurable number of worker processes. While this can speed up CPU-bound test runs, it is mainly useful for IO-bound tests that spend most of their time waiting for data to arrive from someplace else and can benefit from parallelization.

I've adapted the plugin to run a single test in parallel as you want. Download from http://paste.pocoo.org/show/319470/ and save as nose/plugins/repeat.py. Then, in nose/plugins/builtin.py, add the line ('nose.plugins.repeat', 'RepeatMultiProcess'), to builtins. Call like this:

c:\python27\python nose-1.0.0\selftest.py --repeat-processes=2 --repeat-times=3 test2.py

Note: setup/teardown support might be broken. If so, the fix is simple, see comment in line

This seems like something you want in the test definition itself because you want to assert on the aggregation of the results. I would take a look at using multiprocessing in the test. Create a pool to execute your code in parallel. You can use a Queue to aggregate the results.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!