Skip to content

Commit 6bf0120

Browse files
committed
tests: run in parallel
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
1 parent 53bf191 commit 6bf0120

File tree

3 files changed

+31
-22
lines changed

3 files changed

+31
-22
lines changed

noxfile.py

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,24 @@
4242
def tests(session: nox.Session) -> None:
4343
"""Run test suite with pytest."""
4444

45-
coverage_file = f".coverage.{sys.platform}.{session.python}"
45+
coverage_file = f".coverage.pypi.{sys.platform}.{session.python}"
4646

4747
session.create_tmp() # Fixes permission errors on Windows
4848
session.install(*PYPROJECT["dependency-groups"]["test"], "uv")
4949
session.install("-e.[tox_to_nox]")
50-
extra_env = {"PYTHONWARNDEFAULTENCODING": "1"}
5150
session.run(
5251
"pytest",
5352
"--cov",
5453
"--cov-config",
5554
"pyproject.toml",
5655
"--cov-report=",
56+
"--numprocesses=auto",
57+
"-m",
58+
"not conda",
5759
*session.posargs,
5860
env={
61+
"PYTHONWARNDEFAULTENCODING": "1",
5962
"COVERAGE_FILE": coverage_file,
60-
**extra_env,
6163
},
6264
)
6365

@@ -77,42 +79,47 @@ def minimums(session: nox.Session) -> None:
7779
session.run("pytest", *session.posargs)
7880

7981

80-
@nox.session(venv_backend="conda", default=bool(shutil.which("conda")))
81-
def conda_tests(session: nox.Session) -> None:
82-
"""Run test suite set up with conda."""
82+
def xonda_tests(session: nox.Session, xonda: str) -> None:
83+
"""Run test suite set up with conda/mamba/etc."""
84+
85+
coverage_file = f".coverage.{xonda}.{sys.platform}.{session.python}"
86+
8387
session.conda_install(
8488
"--file", "requirements-conda-test.txt", channel="conda-forge"
8589
)
8690
session.install("-e.", "--no-deps")
8791
# Currently, this doesn't work on Windows either with or without quoting
8892
if not sys.platform.startswith("win32"):
8993
session.conda_install("requests<99")
90-
session.run("pytest", *session.posargs)
94+
session.run(
95+
"pytest",
96+
"--cov",
97+
"--cov-config",
98+
"pyproject.toml",
99+
"--cov-report=",
100+
"-m",
101+
"conda",
102+
*session.posargs,
103+
env={"COVERAGE_FILE": coverage_file},
104+
)
105+
106+
107+
@nox.session(venv_backend="conda", default=bool(shutil.which("conda")))
108+
def conda_tests(session: nox.Session) -> None:
109+
"""Run test suite set up with conda."""
110+
xonda_tests(session, "conda")
91111

92112

93113
@nox.session(venv_backend="mamba", default=shutil.which("mamba"))
94114
def mamba_tests(session: nox.Session) -> None:
95115
"""Run test suite set up with mamba."""
96-
session.conda_install(
97-
"--file", "requirements-conda-test.txt", channel="conda-forge"
98-
)
99-
session.install("-e.", "--no-deps")
100-
if not sys.platform.startswith("win32"):
101-
session.conda_install("requests<99")
102-
session.run("pytest", *session.posargs)
116+
xonda_tests(session, "mamba")
103117

104118

105119
@nox.session(venv_backend="micromamba", default=shutil.which("micromamba"))
106120
def micromamba_tests(session: nox.Session) -> None:
107121
"""Run test suite set up with micromamba."""
108-
session.conda_install(
109-
"--file", "requirements-conda-test.txt", channel="conda-forge"
110-
)
111-
# Currently, this doesn't work on Windows either with or without quoting
112-
session.install("-e.", "--no-deps")
113-
if not sys.platform.startswith("win32"):
114-
session.conda_install("requests<99")
115-
session.run("pytest", *session.posargs)
122+
xonda_tests(session, "micromamba")
116123

117124

118125
@nox.session(default=False)

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ test = [
7575
"pytest>=7.4; python_version>='3.12'",
7676
"pytest>=7; python_version<'3.12'",
7777
"pytest-cov>=3",
78+
"pytest-xdist>=3",
7879
]
7980
docs = [
8081
"myst-parser",

requirements-conda-test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ httpx
66
jinja2
77
pbs-installer[all]>=2025.1.6
88
pytest
9+
pytest-xdist
910
tox>=4.0.0
1011
virtualenv >=20.14.1

0 commit comments

Comments
 (0)