代码之家  ›  专栏  ›  技术社区  ›  smarie

如何从pytest钩子内部知道是否启用了pytest xdist?

  •  0
  • smarie  · 技术社区  · 6 年前

    pytest -n

    def pytest_sessionfinish(session):
        try:
            pytest_worker_id = session.config.slaveinput['slaveid']
        except AttributeError:
            # TODO disambiguate: are we the xdist master node or the "main" pytest node with xdist deactivated?
            ...
    

    注意:这是为了摆脱这种尝试 conftest.py example

    谨致问候

    0 回复  |  直到 6 年前
    推荐文章