[Pytest]运行指定的case
2021/6/3 18:26:10
本文主要是介绍[Pytest]运行指定的case,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
运行指定的case
当我们写了较多的cases时,如果每次都要全部运行一遍,无疑是很浪费时间的,通过指定case来运行就很方便了。
例子代码:
test_aa.py
class TestClassOne(object): def test_one(self): x = "this" assert 't'in x def test_two(self): x = "hello" assert hasattr(x, 'check') class TestClassTwo(object): def test_one(self): x = "iphone" assert 'p'in x def test_two(self): x = "apple" assert hasattr(x, 'check')
运行模式:
模式1:直接运行test_aa.py文件中的所有cases:
pytest test_aa.py
模式2:运行test_aa.py文件中的TestClassOne这个class下的两个cases:
pytest test_aa.py::TestClassOne
模式3:运行test_aa.py文件中的TestClassTwo这个class下的test_one:
pytest test_aa.py::TestClassTwo::test_one
注意:定义class时,需要以T开头,不然pytest是不会去运行该class的。
这篇关于[Pytest]运行指定的case的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-06-26小白家庭 nas 搭建方案-icode9专业技术文章分享
- 2024-06-23AI大模型企业应用实战(14)-langchain的Embedding
- 2024-06-23AI大模型企业应用实战(15)-langchain核心组件
- 2024-06-23AI大模型企业应用实战(16)-langchain核心组件
- 2024-06-23AI 大模型企业应用实战(06)-初识LangChain
- 2024-06-19EntBot.ai: AI Website Chatbot for Product Guides and Development Doc
- 2024-06-17zero-shot-learning-definition-examples-comparison
- 2024-06-06Package Easy(基于 NSIS 的打包exe安装包工具)使用方法-icode9专业技术文章分享
- 2024-06-06基于 casdoor 的 ELK 开源登录认证解决方案: elk-auth-casdoor-icode9专业技术文章分享
- 2024-05-29Elasticsearch慢查询日志配置