当前位置:网站首页>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

边栏推荐
- 实现strStr() II
- FE - weex 开发 之 使用 weex-ui 组件与配置使用
- 实习生跑路留了一个大坑,搞出2个线上问题,我被坑惨了
- automation - Jenkins pipline 执行 nodejs 命令时,提示 node: command not found
- Common means of modeling: combination
- 数据科学【九】:SVD(二)
- FE - 微信小程序 - 蓝牙 BLE 开发调研与使用
- The Chinese word segmentation task is realized by using traditional methods (n-gram, HMM, etc.), neural network methods (CNN, LSTM, etc.) and pre training methods (Bert, etc.)
- TensorRT的功能
- Learn about various joins in SQL and their differences
猜你喜欢

日期时间API详解

实习生跑路留了一个大坑,搞出2个线上问题,我被坑惨了

CUDA中的线程层次

Redis - big key problem

Pbootcms collection and warehousing tutorial quick collection release

Sparse array (nonlinear structure)

阿里云MFA绑定Chrome浏览器

代码技巧——Controller参数注解@RequestParam

Learn about various joins in SQL and their differences

Find the highest value of the current element Z-index of the page
随机推荐
Introduce two automatic code generators to help improve work efficiency
MySql索引
Thread hierarchy in CUDA
Tensorrt command line program
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?
Log (common log framework)
利用NVIDIA GPU将Minecraft场景渲染成真实场景
Sentinel rules persist to Nacos
Latest CUDA environment configuration (win10 + CUDA 11.6 + vs2019)
程序员的自我修养—找工作反思篇
Distributed transactions: the final consistency scheme of reliable messages
Data science [9]: SVD (2)
Data science [viii]: SVD (I)
Sentinel规则持久化到Nacos
Function execution space specifier in CUDA
Redis——大Key问题
20201025 Visual Studio2019 QT5.14 信号和槽功能的使用
最新CUDA环境配置(Win10 + CUDA 11.6 + VS2019)
DeprecationWarning: .ix is deprecated. Please use.loc for label based indexing or.iloc for positi
Code skills - Controller Parameter annotation @requestparam