python-web-test icon indicating copy to clipboard operation
python-web-test copied to clipboard

add parallelization level/mode support

Open yashaka opened this issue 4 years ago • 2 comments

yashaka avatar Mar 11 '21 14:03 yashaka

let's keep as simple as passing -n 4, -n auto to pytest, without supporting corresponding env vars, just to keep things simpler...

Just in case, the solution should be based on https://docs.pytest.org/en/latest/reference.html#_pytest.hookspec.pytest_load_initial_conftests

But to use it, we have to build our own plugin, using conftest is not enough...

yashaka avatar Mar 12 '21 06:03 yashaka

Just in case, it might look something like that in the external plugin (yet it can placed locally in this repo, and probably should...)

def pytest_load_initial_conftests(args):
    import sys
    if "xdist" in sys.modules:  # pytest-xdist plugin
        if not config.settings.parallelize:
            return

        asked = config.settings.parallelize_in_exact_subprocess_number
        num = str(asked) or 'auto'
        args[:] = ["-n", num] + args

yashaka avatar Mar 12 '21 06:03 yashaka