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

相关推荐
思则变2 天前
[Pytest][Part 1]Pytest 自动化测试框架
pytest
思则变4 天前
[Pytest] [Part 2]增加 log功能
开发语言·python·pytest
思则变4 天前
[Pytest][Part 3]检测python package状态
pytest
cooldream200918 天前
pytest 框架详解与实战指南
pytest·测试
慕城南风18 天前
【pytest进阶】Pytest之conftest详解
pytest
编程小白gogogo19 天前
AI自动化测试速成(Pytest框架)
pytest
慕城南风19 天前
【pytest进阶】pytest详解及进阶使用
linux·服务器·pytest
Tom Boom1 个月前
Pytest断言全解析:掌握测试验证的核心艺术
自动化测试·python·测试开发·pytest
不要一直敲门1 个月前
初学 pytest 记录
pytest