From b454f76f72dea65db9d360dc1bf51b8ddb76149d Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Mon, 2 Nov 2020 13:17:53 +0100 Subject: [PATCH] Count CPU cores via psutil for parallel testing psutil does a much better job at accurately counting CPU cores, of which pytest-xdist takes advantage for the purposes of running tests concurrently. --- pyproject.toml | 1 + requirements/test.pip | 2 +- tasks.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1cf84312..cbe7642e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,6 +49,7 @@ typogrify = "^2.0" sphinx = "^3.0" sphinx_rtd_theme = "^0.5" livereload = "^2.6" +psutil = {version = "^5.7", optional = true} pytest = "^6.0" pytest-cov = "^2.8" pytest-pythonpath = "^0.7.3" diff --git a/requirements/test.pip b/requirements/test.pip index 647a8694..d36405f0 100644 --- a/requirements/test.pip +++ b/requirements/test.pip @@ -2,7 +2,7 @@ Pygments==2.6.1 pytest pytest-cov -pytest-xdist +pytest-xdist[psutil] # Optional Packages Markdown >= 3.1 diff --git a/tasks.py b/tasks.py index 76c48834..171a9711 100644 --- a/tasks.py +++ b/tasks.py @@ -14,7 +14,7 @@ VENV_PATH = Path(ACTIVE_VENV) if ACTIVE_VENV else (VENV_HOME / PKG_NAME) VENV = str(VENV_PATH.expanduser()) VENV_BIN = Path(VENV) / Path(BIN_DIR) -TOOLS = ["poetry", "pre-commit"] +TOOLS = ["poetry", "pre-commit", "psutil"] POETRY = which("poetry") if which("poetry") else (VENV_BIN / "poetry") PRECOMMIT = ( which("pre-commit") if which("pre-commit") else (VENV_BIN / "pre-commit")