除非存在参数,否则跳过 pytest [英] Skipping pytest unless a parameter is present
本文介绍了除非存在参数,否则跳过 pytest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用 unittest.skiptest 但如果在命令行给出参数,则只跳过测试.这让我可以更轻松地进行集成测试.我该怎么做?
I want to use unittest.skiptest but only skip a test if a parameter is given at command line. This lets me do integration tests easier. How can I do this?
推荐答案
文档中充满了有用的信息.你会找到你想要的 此处.
The documentation is filled with helpful information. You'll find what you are looking for here.
根本不需要使用skiptest.
No need to use skiptest at all.
基本上,只需使用 conftest.py
文件定义一个新的命令行选项,然后用新的注释标记测试.注意:注解和参数可以不同..
Basically, just use the conftest.py
file to define a new command line option and then go about marking the tests with your new annotation. Note: The annotation and parameter can be different..
这篇关于除非存在参数,否则跳过 pytest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文