当前位置:网站首页>(6) Decorator extension [email protected] Principle of use
(6) Decorator extension [email protected] Principle of use
2022-07-24 02:43:00 【It's hard to recover】
( One )@pytest.mark.XXX How did it happen ?
Children's shoes that have played interface automation have been used pytest, Basically, it is realized by decorators , In the last few articles, we talked about the operating principle of the decorator , This time we expand a new knowledge point :@pytest.mark.XXX What is the implementation principle ?
import pytest
@pytest.mark.skip
def test():
passLet's take an example :
@pytest.mark.skip It's actually using pytest In the module mark This object .skip Method
@ modular . object . Method
( Two ) Let's implement a decorator of this form by ourselves
(1) We build a new one lemon.py file , Create a Mark class , Write the inside skip function ,skip There is a nested function in the function wrapper.

(2) Build another one demo1_ Decorator extension .py file , Create a test2 Method , then @lemon.mark.skip, Finally, call below test2() try .

Print the results :
----skip----1
------test2------
----skip----2
Let's try the source code for you
from py09_07day import lemon
class Mark:
def skip(self, func):
def wrapper(*args, **kwargs):
print("----skip----1")
res = func()
print("----skip----2")
return res
return wrapper
mark = Mark()
# @lemon.mark.skip ===> @lemon This class .mark object . Method
# @skip test2 = skip(test2)
@lemon.mark.skip
def test2():
print('------test2------')
test2()
# Print the results
----skip----1
------test2------
----skip----2边栏推荐
- 软考---程序设计语言基础(上)
- Description of relevant resolutions in video on demand
- 22 -- 二叉搜索树的范围和
- Unity TimeLine使用教程
- How to judge null for different types of fields, sets, lists / sets / maps, and objects
- 攻防世界WEB练习区(webshell、command_execution、simple_js)
- Unscramble the category and application principle of robot vision
- Audio processing based on time-frequency diagram matlab
- 程序员必备技能----断点调试(IDEA版)
- Only beautiful ones can be opened
猜你喜欢

Make life full of happiness
![js傳參時傳入 string有數據;傳入 number時沒有數據;2[0]是對的!number類型數據可以取下標](/img/4e/3d0c25d9579b6d5c00473048dbbd83.png)
js傳參時傳入 string有數據;傳入 number時沒有數據;2[0]是對的!number類型數據可以取下標

UIE: 信息抽取的大一统模型

Live800: there is nothing trivial about customer service. Don't let service destroy the reputation of the enterprise

Implementation of POP3 client code
![[diary of supplementary questions] [2022 Niuke summer school 1] c-grab the seat](/img/86/1cf3bbc53d9365bb95dae6d532e276.png)
[diary of supplementary questions] [2022 Niuke summer school 1] c-grab the seat

Unity TimeLine使用教程

TP5 framework link promotion project

攻防世界WEB练习区(view_source、get_post、robots)

Doodle icons - a free commercial graffiti style icon library, cute, light and unique
随机推荐
SSM的技术论坛含前后台
攻防世界WEB练习区(view_source、get_post、robots)
Fasterrcnn sample code test 1: make anchor_ generator = None
[diary of supplementary questions] [2022 Niuke summer multi school 2] k-link with bracket sequence I
I'm a novice. I heard that there is a breakeven financial product in opening an account. What is it?
Use the pagoda panel to plan tasks and automatically push the website to Baidu for inclusion
Unity timeline tutorial
X Actual combat - Cloud Server
"Why should we do IVX?"—— Interview with IVX CEO Meng Zhiping to understand IVX corporate culture
Responsive pbootcms template decoration design website
如何获取步态能量图gei
[untitled]
Discussion on sending redundant API requests for Spartacus UI transfer state of SAP e-commerce cloud
Custom log annotation, request fetching
NumberOptional:一个字符串转数字的工具
[diary of supplementary questions] [2022 Niuke summer school 1] c-grab the seat
无需编码,自动实现“异步 Request-Reply”模式
Mysql database, grouping function
[FPGA tutorial case 38] communication case 8 - serial parallel serial data transmission based on FPGA
Dynamically set the navigationbartitletext of the applet