Skip to content

Commit ddf9d48

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

3 files changed

Lines changed: 31 additions & 21 deletions

File tree

noxfile.py

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
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")
@@ -55,10 +55,13 @@ def tests(session: nox.Session) -> None:
5555
"--cov-config",
5656
"pyproject.toml",
5757
"--cov-report=",
58+
"--numprocesses=auto",
59+
"-m",
60+
"not conda",
5861
*session.posargs,
5962
env={
63+
"PYTHONWARNDEFAULTENCODING": "1",
6064
"COVERAGE_FILE": coverage_file,
61-
**extra_env,
6265
},
6366
)
6467

@@ -78,42 +81,47 @@ def minimums(session: nox.Session) -> None:
7881
session.run("pytest", *session.posargs)
7982

8083

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."""
84+
def xonda_tests(session: nox.Session, xonda: str) -> None:
85+
"""Run test suite set up with conda/mamba/etc."""
86+
87+
coverage_file = f".coverage.{xonda}.{sys.platform}.{session.python}"
88+
8489
session.conda_install(
8590
"--file", "requirements-conda-test.txt", channel="conda-forge"
8691
)
8792
session.install("-e.", "--no-deps")
8893
# Currently, this doesn't work on Windows either with or without quoting
8994
if not sys.platform.startswith("win32"):
9095
session.conda_install("requests<99")
91-
session.run("pytest", *session.posargs)
96+
session.run(
97+
"pytest",
98+
"--cov",
99+
"--cov-config",
100+
"pyproject.toml",
101+
"--cov-report=",
102+
"-m",
103+
"conda",
104+
*session.posargs,
105+
env={"COVERAGE_FILE": coverage_file},
106+
)
107+
108+
109+
@nox.session(venv_backend="conda", default=bool(shutil.which("conda")))
110+
def conda_tests(session: nox.Session) -> None:
111+
"""Run test suite set up with conda."""
112+
xonda_tests(session, "conda")
92113

93114

94115
@nox.session(venv_backend="mamba", default=shutil.which("mamba"))
95116
def mamba_tests(session: nox.Session) -> None:
96117
"""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)
118+
xonda_tests(session, "mamba")
104119

105120

106121
@nox.session(venv_backend="micromamba", default=shutil.which("micromamba"))
107122
def micromamba_tests(session: nox.Session) -> None:
108123
"""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)
124+
xonda_tests(session, "micromamba")
117125

118126

119127
@nox.session(default=False)

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ test = [
7474
"pytest>=7.4; python_version>='3.12'",
7575
"pytest>=7; python_version<'3.12'",
7676
"pytest-cov>=3",
77+
"pytest-xdist>=3",
7778
]
7879
docs = [
7980
"docutils<0.22", # Waiting for sphinx-tabs release

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)