[英]Recommendations for integrating argparse scripts in Python's unit tests via nose or pytest
My recent project consists mainly of an API for which I have written some unit tests for pytest
and nose
. 我最近的项目主要是一个API,我已经为
pytest
和nose
编写了一些单元测试。
I have some scripts in this bundle that make use of this API and was wondering if there is a good way to include them in those unit tests. 我在这个包中有一些脚本使用了这个API,并且想知道是否有一种很好的方法将它们包含在那些单元测试中。
There would be the subprocess.call
way, but I think this is rather ugly. 会有
subprocess.call
方式,但我觉得这很难看。 Do you have any recommendations how I can integrate those scripts? 您对如何集成这些脚本有任何建议吗?
Rewrite your scripts in python if it not already. 如果还没有,请在python中重写脚本。 And just import it in your tests.
并在测试中导入它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.