是否可以同时使用Nose进行一次测试? [英] Is it possible to use Nose to run one test multiple times, concurrently?

查看:86
本文介绍了是否可以同时使用Nose进行一次测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 nose 进行单个测试同时(跨多个进程)并将结果汇​​总为单个通过/失败结果?

Is it possible to use nose to run a single test concurrently (across multiple processes) and aggregate the result in to a single pass/fail result?

我们需要同时运行多次相同的测试,以确保资源锁定不会受到影响.如果鼻子不能做到这一点,是否有遵循特定的测试/设计模式来实现这一目标?

We have the need to run the same test multiple times concurrently to ensure resource locking isn't being affected. If nose can't do this, is there a specific testing/design pattern to follow to achieve this?

推荐答案

可以

使用鼻子.插件.多进程 插件,您可以并行运行测试 跨越可配置数量的工作人员 流程.虽然这可以加快 CPU绑定测试运行,主要是 对于花费在IO上的测试很有用 他们大部分时间在等待数据 从其他地方到达,可以 受益于并行化.

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.

我已经调整了插件以根据需要并行运行单个测试.从 http://paste.pocoo.org/show/319470/下载并另存为nose/plugins/repeat.py.然后,在nose/plugins/builtin.py中,将行('nose.plugins.repeat', 'RepeatMultiProcess'),添加到builtins.像这样打电话:

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

这篇关于是否可以同时使用Nose进行一次测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆