Which xdist worker is running this test?
QuizMediumPython onlyAsked in: Accenture, Capgemini, Infosys, SaaS Labs, Swiggy, TCS
Each xdist worker should use its own test account. How does a fixture know which worker it is on?
- Request the
worker_idfixture from pytest-xdist; it is "gw0", "gw1" and so on, or "master" without xdist - Read
os.getpid()and map it by hand - Workers cannot be told apart
- Use
threading.current_thread().name
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.