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但是还是从整个用例的开始执行

相关推荐
水银嘻嘻5 小时前
09 接口自动化-用例管理框架pytest之allure报告定制以及数据驱动
自动化·pytest
程序员三藏1 天前
接口自动化测试框架(pytest+allure+aiohttp+ 用例自动生成)
自动化测试·软件测试·python·职场和发展·测试用例·pytest·接口测试
水银嘻嘻2 天前
08 接口自动化-用例管理框架pytest之fixtrue,conftest.py,allure报告以及logo定制
python·自动化·pytest
A_Tai23333333 天前
PyTest
pytest
bjwuzh8 天前
使用pytest实现参数化后,控制台输出的日志是乱码
pytest
2025年一定要上岸9 天前
pytest框架 - 第二集 allure报告
pytest
头疼的程序员11 天前
allure生成测试报告(搭配Pytest、allure-pytest)
测试工具·pytest
文人sec11 天前
接口自动化测试设计思路--设计实战
python·https·单元测试·自动化·pytest
测试开发Kevin13 天前
从投入产出、效率、上手难易度等角度综合对比 pytest 和 unittest 框架
python·pytest
测试开发Kevin15 天前
以pytest_addoption 为例,讲解pytest框架中钩子函数的应用
python·pytest