From 84865d16dc99a8a491e3973edb4eccc8d6df5018 Mon Sep 17 00:00:00 2001 From: Russell Martin Date: Sat, 29 Apr 2023 01:57:28 -0400 Subject: [PATCH] Run `tox` tests in parallel --- changes/1247.misc.rst | 1 + pyproject.toml | 2 ++ setup.cfg | 2 ++ tests/conftest.py | 2 +- tox.ini | 7 +++++-- 5 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 changes/1247.misc.rst diff --git a/changes/1247.misc.rst b/changes/1247.misc.rst new file mode 100644 index 000000000..b6ef90572 --- /dev/null +++ b/changes/1247.misc.rst @@ -0,0 +1 @@ +Python tests are now run in parallel via ``tox``. diff --git a/pyproject.toml b/pyproject.toml index 9c1d2e449..6b24450c0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,9 @@ requires = ["setuptools>=60", "setuptools_scm[toml]>=7.0"] build-backend = "setuptools.build_meta" [tool.coverage.run] +concurrency = ["multiprocessing", "thread"] parallel = true +sigterm = true branch = true relative_files = true source_pkgs = ["briefcase"] diff --git a/setup.cfg b/setup.cfg index 62ccd3023..448c866a4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -91,8 +91,10 @@ install_requires = # ensure environment consistency. dev = coverage[toml] == 7.2.3 + coverage-enable-subprocess == 1.0 pre-commit == 3.2.2 pytest == 7.3.1 + pytest-xdist == 3.2.1 setuptools_scm[toml] == 7.1.0 tox == 4.4.12 docs = diff --git a/tests/conftest.py b/tests/conftest.py index 7bacd6765..b7ef8d62f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -55,7 +55,7 @@ def no_print(monkeypatch): @pytest.fixture def sleep_zero(monkeypatch): - """Replace all calls to ``time.sleep(x)`` with ``time.sleep(0).""" + """Replace all calls to ``time.sleep(x)`` with ``time.sleep(0)``.""" monkeypatch.setattr(time, "sleep", lambda x: _sleep(0)) diff --git a/tox.ini b/tox.ini index 4c0099bba..3bd4585e5 100644 --- a/tox.ini +++ b/tox.ini @@ -7,8 +7,11 @@ download = True # The leading comma generates the "py" environment. [testenv:py{,38,39,310,311,312}{,-coverage}] passenv = - # LOCALAPPDATA is needed to test data directory creation on Windows. + # Needed on Windows to test data directory creation LOCALAPPDATA +setenv = + # Start Python such that coverage is possible in subprocesses + COVERAGE_PROCESS_START = {toxinidir}/pyproject.toml extras = dev # 2023-04-22 The virtualenv used by Tox has pip 23.1 pinned into it @@ -16,7 +19,7 @@ extras = # need to force pip to be updated. download = True commands = - python -m coverage run -m pytest -vv {posargs} + python -m coverage run -m pytest {posargs:-n auto -vv} coverage : python -m coverage combine coverage : python -m coverage report