pytest中的pytest.ini

python 复制代码
[pytest]
filterwarnings =
ignore::DeprecationWarning
addopts = -v -s
markers =
uat:1
smok:2
log_cli=1
xfail_strict = True

filterwarnings =

ignore::DeprecationWarning

这个的功能就是

python 复制代码
test_login.py::Test_login::test_login_correct_password PASSED
============================================================================ warnings summary ============================================================================= 
..\..\..\applicationloadPath\pythonPath\Lib\site-packages\selenium\webdriver\remote\remote_connection.py:24
  C:\applicationloadPath\pythonPath\Lib\site-packages\selenium\webdriver\remote\remote_connection.py:24: DeprecationWarning: 'urllib3[secure]' extra is deprecated and will 
be removed in a future release of urllib3 2.x. Read more in this issue: https://github.com/urllib3/urllib3/issues/2680
    import urllib3

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=============================================================== 1 passed, 3 deselected, 1

在consel中去掉上面的错误信息,让界面更干净一点

python 复制代码
markers =
uat:1
smok:2

这个就是为测试用例自定义标签,但是有一个问题就是只能在CMD中实现通过标签来执行测试用例,在代码中不能实现通过标签执行指定的测试用例

如果在代码中的主函数中通过命令的方式好像没能实现

如图所示,按照上面代码块,应该只执行方法名为test_login_correct_username但是还是从整个用例的开始执行

相关推荐
姚青&20 小时前
软件测试基础概念
单元测试·pytest
爆更小哇4 天前
pytest集成Allure报告教程
python·测试工具·pytest·接口测试·allure
gCode Teacher 格码致知4 天前
Python提高:pytest的简单案例-由Deepseek产生
python·pytest
gCode Teacher 格码致知5 天前
Python提高: unittest和 pytest的使用方法-由Deepseek产生
开发语言·python·pytest
我的xiaodoujiao8 天前
API 接口自动化测试详细图文教程学习系列11--Requests模块3--测试练习
开发语言·python·学习·测试工具·pytest
我的xiaodoujiao9 天前
API 接口自动化测试详细图文教程学习系列12--Requests模块4--测试实践操作
python·学习·测试工具·pytest
Lightning-py10 天前
pytest 软断言的几种方式
pytest
Lightning-py10 天前
pytest后置处理方式
pytest
爆更小哇12 天前
Python自动化测试:pytest新手快速入门指南
python·测试工具·自动化·pytest
qq_4523962312 天前
第一篇:基座选型 —— 为什么 Pytest 是自动化的终点?
自动化·pytest