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

相关推荐
2601_9620782310 小时前
Python接口自动化框架:pytest
python·pytest·接口自动化·测试框架·restfulapi
2601_9620781914 小时前
Appium+Python+pytest自动化测试框架详解
自动化测试·python·appium·pytest·移动应用
2601_962284502 天前
安卓APP UI自动化测试:Python + UiAutomator2 + pytest + pytest-html
python·pytest·uiautomator2·ui自动化测试·安卓app
2601_962300812 天前
基于pytest的接口自动化测试:使用requests模块的实战项目与接口关联方法详解
接口自动化测试·测试用例·pytest·接口关联·requests模块
2601_962300812 天前
Python + Requests + Pytest + Excel + Allure:接口自动化测试项目实战
python·excel·pytest·allure·requests
11路没有终点3 天前
Pytest 安装、版本与第一个测试用例
测试用例·pytest
11路没有终点4 天前
pytest 参数化与 Mark 标记
pytest
2601_962296284 天前
五种Python自动化测试框架汇总,附学习方法
自动化测试·pytest·unittest·robotframework·python框架
11路没有终点5 天前
pytest Fixture 进阶:conftest 与依赖注入
pytest
2601_962387828 天前
web自动化测试实战教程【selenium/unittest/pytest】【共193课
selenium·pytest·devops·web自动化测试·unittest