@pytest.fixture(scope="session")
def create_user_access_token():
""" Used to test: refresh and revoke endpoints"""
response_data = oauth_requests.create_user_access_token()
return response_data["token"]
@pytest.fixture(scope="session")
def create_client_access_token():
""" Used to test: refresh and revoke endpoints"""
response_data = oauth_requests.create_client_access_token()
return response_data["token"]
@pytest.mark.parameterize('token', [create_client_access_token, create_user_access_token]
def test(token):
return_data = check(token)
assert return_data.status_code == 200
I understand it's not possible to do the above but how can I replicate this feature? The tests I am writing are identical for both tokens.
the fixtures are functions and request the API to create said token.
@mrBeanBremen Already started refactoring my code with the singleton pattern:). am leaving the function calls separate for flexibility. Thanks!
class Tokens:
__instance = None
def __new__(cls, user_token, client_token):
if cls.__instance is None:
cls.__instance = object.__new__(cls)
cls.__instance.user_token = user_token
cls.__instance.client_token = client_token
return cls.__instance
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.