简体   繁体   English

python:pytest for cmd工具

[英]python: pytest for cmd tools

I created a Python library and a set of Python script around it. 我创建了一个Python库和围绕它的一组Python脚本。 An example of this small script could be something like this rna_ex2x.py : 这个小脚本的示例可能是类似rna_ex2x.py的内容

./rna_ec2x.py
usage: rna_ec2x.py [-h] [--sep SEP] [--chain CHAIN] [--ec-pairs]
                   [--ss-pairs SS_PAIRS] [--pairs-delta]
                   interaction_fn
rna_ec2x.py: error: too few arguments

I want to test these script with pytest. 我想用pytest测试这些脚本。 I know how to test my functions with pytest, but I can't find in the documentation what would be the best practice in testing standalone Python script. 我知道如何使用pytest测试我的功能,但是我无法在文档中找到测试独立Python脚本的最佳实践。 Any suggestions? 有什么建议么?

I don't know what would be the best practice but I simply call my programs using subprocess.call() , check the result code and verify that the program did what it intended to do. 我不知道什么是最佳实践,但是我只是使用subprocess.call()调用程序,检查结果代码并验证程序是否按预期进行。 See my tests as examples. 我的测试为例。

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

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