I am attempting to write a decorator which calls on two additional functions and runs them in addition to the function it is decorating in a specific order.
I have tried something along these lines:
class common():
def decorator(setup, teardown, test):
def wrapper(self):
setup
test
teardown
return wrapper
class run():
def setup(self):
print("in setup")
def teardown(self):
print("in teardown")
@common.decorator(setup, teardown)
def test(self):
print("in test")
The final goal would be to have the decorator make the test run with the following flow setup > test > teardown. I know I am not calling on the setup and teardown correctly however. I would appreciate any help in how I should do this, I am new in using python and my knowledge of decorators involving arguments is limited.