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 天前
AI 帮我写单测:pytest 覆盖率提升 40% 的协作日志
人工智能·pytest·测试驱动开发·代码覆盖率·ai协作开发
lucia_zl4 天前
pytest并发测试,资源问题导致用例失败解决办法
pytest
鱼鱼说测试4 天前
Selenium4+Pytest自动化测试框架实战
pytest
XYiFfang11 天前
【Pytest】解决Pytest中Teardown钩子的TypeError:实例方法与类方法的调用差异
python·pytest
Kingairy12 天前
Pytest 插件:pytest_runtest_protocol
python·pytest
AIZHINAN13 天前
Pytest 插件介绍和开发
测试工具·pytest·插件开发
灰阳阳15 天前
替身演员的艺术:pytest-mock 从入门到飙戏
自动化测试·python·pytest·unit testing·pytest-mock
年年测试18 天前
Playwright与PyTest结合指南
pytest
focksorCr18 天前
pytest 并发执行用例(基于受限的测试资源)
python·pytest