当前位置:网站首页>Pytest (2) mark function
Pytest (2) mark function
2022-07-02 06:33:00 【bthtth】
1\ Mark test cases
pytest.mark. Tag name
It can be used to mark a single test function , Or test class
# file name test_mark.py
import pytest
@pytest.mark.mark_class # Mark the test class , Mark every test function in the class
class Test_mark:
def test_case_1(self):
print("case_1,mark_class")
@pytest.mark.mark_func # Have two tags mark_class,mark_func
def test_case_2(self):
print("caes_2,mark_class,mark_func")
2\ Execute test cases according to labels Enter at the command line pytest -m Tag name
In command line , Switch to test_mark.py Folder in which ,test_mark.py Is the file where the above code is located
Input pytest -m mark_calss Executed by class_class Use cases for tags
Wrong report Unknown pytest.mark.mark_class - is this a typo?
Need to register
stay test_mark.py Root directory baidu Next , establish pytest.ini file
stay pytest.ini Enter the following code in the file
addopts = --strict-markers Strictly match the label name
markers= ^^^^^ Is a custom label
[pytest]
addopts = --strict-markers
markers =
mark_class: marks tests as mark_class (deselect with '-m "not slow"')
mark_func:marks tests as mark_class
And then it's ready to run ,
mark_calss Run two tags in the test class
mark_func Just write a label , Collect two use cases , Execute a use case
You can also filter use cases with logical operators
pytest -m mark_calss and not mark_func function Yes mark_calss But no mark_func The use case , The label expression has double quotation marks , Single quotation marks are not recognized
边栏推荐
猜你喜欢
自学table au
Data science [viii]: SVD (I)
Hydration failed because the initial UI does not match what was rendered on the server.问题原因之一
Introduce two automatic code generators to help improve work efficiency
Summary of advertisement business bug replay
FE - 微信小程序 - 蓝牙 BLE 开发调研与使用
Thread hierarchy in CUDA
Alibaba cloud MFA binding Chrome browser
Redis——热点key问题
栈(线性结构)
随机推荐
Thread hierarchy in CUDA
一口气说出 6 种实现延时消息的方案
Redis---1.数据结构特点与操作
IPv6 experiment and summary
Data science [viii]: SVD (I)
广告业务Bug复盘总结
Top 10 classic MySQL errors
奇葩pip install
实现strStr() II
Summary of WLAN related knowledge points
Introduce two automatic code generators to help improve work efficiency
Uploading attachments using Win32 in Web Automation
Redis——大Key问题
pytest(2) mark功能
qq邮箱接收不到jenkins构建后使用email extension 发送的邮件(timestamp 或 auth.......)
Hydration failed because the initial UI does not match what was rendered on the server. One of the reasons for the problem
阿里云MFA绑定Chrome浏览器
链表(线性结构)
sprintf_s的使用方法
Redis——大Key問題