I'm trying to construct a decorator which can apply more decorators depending of conditions.
I've tried some cases to understand how to reach my goal with following code:
def my_decorator(func):
@allure.description('desc')
@allure.title('title')
def execute_func():
func()
return execute_func()
@my_decorator
def test1():
assert 1 == 1
def test_a():
assert 1 == 2
However running that test doesn't work well since pytest sees only test_a
, and test1
isn't even collected. With that being said I'd love to see how to properly use decorator in the way I'd like to and my next step would be adding parameters to that decorator, something like:
def my_decorator(func, name=None, desc=None, step=None)
and then use 0-3 decorators with the given parameters.
Thanks in advance!