diff --git a/CHANGELOG b/CHANGELOG index fd39bb4..0b2546b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,9 @@ +1.13.1 +------- + +- fix a regression -n 0 now disables xdist again + + 1.13 ------------------------- @@ -16,7 +22,7 @@ - new "--max-slave-restart" option that can be used to control maximum number of times pytest-xdist can restart slaves due to crashes. Thanks to Anatoly Bubenkov for the report and Bruno Oliveira for the PR. - + - release as wheel - "-n" option now can be set to "auto" for automatic detection of number diff --git a/xdist/plugin.py b/xdist/plugin.py index 4b5fad4..5057109 100644 --- a/xdist/plugin.py +++ b/xdist/plugin.py @@ -1,12 +1,20 @@ -import multiprocessing - import py import pytest + +def parse_numprocesses(s): + if s == 'auto': + import multiprocessing + return multiprocessing.cpu_count() + else: + return int(s) + + def pytest_addoption(parser): group = parser.getgroup("xdist", "distributed and subprocess testing") group._addoption('-n', dest="numprocesses", metavar="numprocesses", action="store", + type=parse_numprocesses, help="shortcut for '--dist=load --tx=NUM*popen', " "you can use 'auto' here for auto detection CPUs number on " "host system") @@ -68,13 +76,6 @@ def pytest_configure(config): @pytest.mark.tryfirst def pytest_cmdline_main(config): if config.option.numprocesses: - if config.option.numprocesses == 'auto': - config.option.numprocesses = multiprocessing.cpu_count() - else: - try: - config.option.numprocesses = int(config.option.numprocesses) - except ValueError: - config.option.numprocesses = 1 config.option.dist = "load" config.option.tx = ['popen'] * config.option.numprocesses if config.option.distload: