Am trying to set a decorator on a unit test, the purpose of the decorator is to ensure that a user logins in before accessing other endpoints.
Below is the decorator for logging in :
def login_decorator(*args, **kwargs):
def login_user():
kwargs['self'].client.login(
username=kwargs['email'],
password=kwargs['password'],
)
Then am trying to utilize it on the unit test function as below :
@login_decorator(self=self, email=self.email, password=self.password)
def test_customer_profile_add(self):
response = super().create_customer_profile(self.customer_data)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
however self
is underlines with an error Unresolved reference , how can I achieve passing of the params through the decorator with self.