Skip to content

Commit d808330

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

3 files changed

Lines changed: 31 additions & 22 deletions

File tree

noxfile.py

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

46-
coverage_file = f".coverage.{sys.platform}.{session.python}"
46+
coverage_file = f".coverage.pypi.{sys.platform}.{session.python}"
4747

4848
session.create_tmp() # Fixes permission errors on Windows
4949
session.install(*PYPROJECT["dependency-groups"]["test"], "uv")
5050
session.install("-e.[tox_to_nox,pbs]")
51-
extra_env = {"PYTHONWARNDEFAULTENCODING": "1"}
5251
session.run(
5352
"pytest",
5453
"--cov",
5554
"--cov-config",
5655
"pyproject.toml",
5756
"--cov-report=",
57+
"--numprocesses=auto",
58+
"-m",
59+
"not conda",
5860
*session.posargs,
5961
env={
62+
"PYTHONWARNDEFAULTENCODING": "1",
6063
"COVERAGE_FILE": coverage_file,
61-
**extra_env,
6264
},
6365
)
6466

@@ -78,42 +80,47 @@ def minimums(session: nox.Session) -> None:
7880
session.run("pytest", *session.posargs)
7981

8082

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

93113

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

105119

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

118125

119126
@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
@@ -8,6 +8,7 @@ humanize
88
jinja2
99
pbs-installer>=2025.1.6
1010
pytest
11+
pytest-xdist
1112
tox>=4.0.0
1213
virtualenv >=20.14.1
1314
zstandard

0 commit comments

Comments
 (0)