是否可以使用 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这似乎是您在测试定义本身中想要的东西,因为您想对结果的聚合进行断言。我会看看在测试中使用 multiprocessing 。创建一个池来并行执行代码。您可以使用 队列 来聚合结果。
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.
可以与nose同时运行测试:
我已经调整了该插件以根据需要并行运行单个测试。从 http://paste.pocoo.org/show/319470/ 下载并另存为 <代码>nose/plugins/repeat.py。然后,在
nose/plugins/builtin.py
中,将行('nose.plugins.repeat', 'RepeatMultiProcess'),
添加到builtins
。像这样调用:注意:安装/拆卸支持可能会被破坏。如果是这样,修复很简单,请参阅行中的注释
It is possible to run tests concurrently with nose:
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, innose/plugins/builtin.py
, add the line('nose.plugins.repeat', 'RepeatMultiProcess'),
tobuiltins
. Call like this:Note: setup/teardown support might be broken. If so, the fix is simple, see comment in line