Pytestsetup_method
在xdist
worker_id
fixture 之前执行是否有可能在开始之前获取worker id setup_method
?
例如我有:
内容conftest.py
:
@pytest.fixture(autouse=True)
def worker_id(request):
print("worker")
if hasattr(request.config, 'slaveinput'):
request.config.worker = request.config.slaveinput['slaveid']
else:
request.config.worker = "master"
return request.config.worker
内容test.py
:
class TestSomething:
def setup_method(self):
print("setup")
def test_something(self):
print("test")
输出是:
setup
worker
test