当前位置:网站首页>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
边栏推荐
- Redis---1. Data structure characteristics and operation
- Golang--map扩容机制(含源码)
- [self cultivation of programmers] - Reflection on job hunting Part II
- Warp shuffle in CUDA
- Three suggestions for all students who have graduated and will graduate
- 队列(线性结构)
- 代码技巧——Controller参数注解@RequestParam
- 利用NVIDIA GPU将Minecraft场景渲染成真实场景
- 程序员的自我修养—找工作反思篇
- 标签属性disabled selected checked等布尔类型赋值不生效?
猜你喜欢
随机推荐
Flask-Migrate 检测不到db.string() 等长度变化
NodeJs - Express 中间件修改 Header: TypeError [ERR_INVALID_CHAR]: Invalid character in header content
代码技巧——Controller参数注解@RequestParam
Data science [9]: SVD (2)
稀疏数组(非线性结构)
AWD学习
TensorRT的功能
New version of dedecms collection and release plug-in tutorial tool
程序员的自我修养—找工作反思篇
日期时间API详解
Sentinel Alibaba open source traffic protection component
It is said that Kwai will pay for the Tiktok super fast version of the video? How can you miss this opportunity to collect wool?
Functions of tensorrt
Redis - hot key issues
广告业务Bug复盘总结
[daily question 1] write a function to judge whether a string is the string after the rotation of another string.
MySql索引
selenium备忘录:selenium\webdriver\remote\remote_connection.py:374: ResourceWarning: unclosed<xxxx>解决办法
automation - Jenkins pipline 执行 nodejs 命令时,提示 node: command not found
qq邮箱接收不到jenkins构建后使用email extension 发送的邮件(timestamp 或 auth.......)