Share a login token across tests without a global variable
QuizMediumPython only
Logging in through the API takes 2 seconds, and many tests need the login token. What is the cleanest way to share it?
- A
scope="session"fixture that logs in once and returns the token to every test that asks for it - A global variable set by the first test
- Make every test depend on a login test
- Write the token to a file in the first test
This question is part of Pro+
Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.