python-web-test
python-web-test copied to clipboard
add parallelization level/mode support
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...
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