Skip to content

Commit 9d0b90f

Browse files
committed
tests: run in parallel
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
1 parent ecd52d7 commit 9d0b90f

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

noxfile.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def tests(session: nox.Session) -> None:
5454
"--cov-config",
5555
"pyproject.toml",
5656
"--cov-report=",
57+
"--numprocesses=auto",
5758
*session.posargs,
5859
env={
5960
"COVERAGE_FILE": coverage_file,
@@ -87,7 +88,7 @@ def conda_tests(session: nox.Session) -> None:
8788
# Currently, this doesn't work on Windows either with or without quoting
8889
if not sys.platform.startswith("win32"):
8990
session.conda_install("requests<99")
90-
session.run("pytest", *session.posargs)
91+
session.run("pytest", "--numprocesses=auto", *session.posargs)
9192

9293

9394
@nox.session(venv_backend="mamba", default=shutil.which("mamba"))
@@ -99,7 +100,7 @@ def mamba_tests(session: nox.Session) -> None:
99100
session.install("-e.", "--no-deps")
100101
if not sys.platform.startswith("win32"):
101102
session.conda_install("requests<99")
102-
session.run("pytest", *session.posargs)
103+
session.run("pytest", "--numprocesses=auto", *session.posargs)
103104

104105

105106
@nox.session(venv_backend="micromamba", default=shutil.which("micromamba"))
@@ -112,7 +113,7 @@ def micromamba_tests(session: nox.Session) -> None:
112113
session.install("-e.", "--no-deps")
113114
if not sys.platform.startswith("win32"):
114115
session.conda_install("requests<99")
115-
session.run("pytest", *session.posargs)
116+
session.run("pytest", "--numprocesses=auto", *session.posargs)
116117

117118

118119
@nox.session(default=False)

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ test = [
7373
"pytest>=7.4; python_version>='3.12'",
7474
"pytest>=7; python_version<'3.12'",
7575
"pytest-cov>=3",
76+
"pytest-xdist>=3",
7677
]
7778
docs = [
7879
"myst-parser",

requirements-conda-test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ colorlog >=2.6.1,<7.0.0
44
dependency-groups >=1.1
55
jinja2
66
pytest
7+
pytest-xdist
78
tox>=4.0.0
89
virtualenv >=20.14.1

tests/test_sessions.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
from nox.logger import logger
4242

4343
HAS_CONDA = shutil.which("conda") is not None
44-
has_conda = pytest.mark.skipif(not HAS_CONDA, reason="Missing conda command.")
44+
has_conda = pytest.mark.skipif(not HAS_CONDA, reason="Missing conda command.")(
45+
pytest.mark.xdist_group(name="conda")
46+
)
4547

4648
DIR = Path(__file__).parent.resolve()
4749

tests/test_virtualenv.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@
4545
VIRTUALENV_VERSION = metadata.version("virtualenv")
4646

4747
has_uv = pytest.mark.skipif(not HAS_UV, reason="Missing uv command.")
48-
has_conda = pytest.mark.skipif(not HAS_CONDA, reason="Missing conda command.")
48+
has_conda = pytest.mark.skipif(not HAS_CONDA, reason="Missing conda command.")(
49+
pytest.mark.xdist_group(name="conda")
50+
)
4951

5052

5153
class TextProcessResult(NamedTuple):

0 commit comments

Comments
 (0)