我如何使用nosetest来运行shell脚本或另一个python脚本
是一个扩展 PyUnit 的测试运行器。是否可以编写例如
$ nosetests --with-shell myTest.py -myargs test
如果没有,那么是否有插件,或者我需要自己开发它。 有什么建议吗?
is a test runner which extends PyUnit. Is it possible to write e.g
$ nosetests --with-shell myTest.py -myargs test
If not, then is there a plugin, or do i need to develop it myself.
Any suggestions ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Nose不是一般的测试用具。它是专门运行 Python 单元测试的 Python 工具。
因此,虽然您可以编写扩展让它执行脚本并根据退出状态或输出字符串将它们标记为成功或失败,我认为这是试图硬塞线束去做一些它并不真正想做的事情。
您应该将测试打包为 Python 函数或类,然后让它们使用库来运行外部脚本,该脚本的输出或行为会被转换为nose 可以解释的内容,而不是扩展nose 来直接运行脚本。
另外,我对鼻子进行了一些实验,发现与 py.test 相比,它的扩展机制相当笨拙。你可能想尝试一下。
Nose is not a general test harness. It's specifically a Python harness which runs Python unit tests.
So, while you can write extensions for it to execute scripts and mark them as successes or failures based on the exit status or an output string, I think it's an attempt to shoehorn the harness into doing something it's not really meant to do.
You should package your tests as Python functions or classes and then have them use a library to run external scripts the output or behaviour of which is translated into something that nose can interpret rather than extend nose to directly run scripts.
Also, I've experimented with nose a bit and found it's extension mechanism quite clumsy compared to py.test. You might want to give that a shot.