简体   繁体   English

我如何使用nosetest来运行shell脚本或其他python脚本

[英]How can i use nosetest to run an shell script or another python script

nose 鼻子

is a test runner which extends PyUnit. 是一个扩展PyUnit的测试运行器。 Is it possible to write eg 有可能写出例如

$ nosetests --with-shell myTest.py -myargs test

If not, then is there a plugin, or do i need to develop it myself. 如果没有,那么是否有插件,或者我需要自己开发它。 Any suggestions ? 有什么建议 ?

Nose is not a general test harness. 鼻子不是一般的测试工具。 It's specifically a Python harness which runs Python unit tests. 它特别是一个运行Python单元测试的Python工具。

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. 您应该将测试打包为Python函数或类,然后让它们使用库来运行外部脚本,其输出或行为将转换为鼻子可以解释的内容,而不是扩展到直接运行脚本。

Also, I've experimented with nose a bit and found it's extension mechanism quite clumsy compared to py.test . 此外,我尝试了一下鼻子,发现它的扩展机制与py.test相比非常笨拙。 You might want to give that a shot. 你可能想要一试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM