Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ jobs:
- name: Install Nox-under-test (uv)
run: uv pip install --system .
- name: Run tests on ${{ matrix.os }}
run: nox --session "tests-${{ matrix.python-version }}" -- --full-trace
run: nox --session "tests-${{ matrix.python-version }}" -- --durations=10
- name: Run min-version tests on ${{ matrix.os }}
run: nox --session minimums --force-python="${{ matrix.python-version }}" -- --full-trace
run: nox --session minimums --force-python="${{ matrix.python-version }}" -- --durations=10
- name: Run Conda tests
if: matrix.python-version == '3.14'
run: nox --session "conda_tests" -- --full-trace
run: nox --session "conda_tests" -- --durations=5
- name: Save coverage report
uses: actions/upload-artifact@v5
with:
Expand Down
82 changes: 45 additions & 37 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@

from __future__ import annotations

import contextlib
import functools
import os
import shutil
import sqlite3
import sys

import nox
Expand All @@ -43,29 +41,30 @@
def tests(session: nox.Session) -> None:
"""Run test suite with pytest."""

coverage_file = f".coverage.{sys.platform}.{session.python}"
coverage_file = f".coverage.pypi.{sys.platform}.{session.python}"
env = {
"PYTHONWARNDEFAULTENCODING": "1",
"COVERAGE_FILE": coverage_file,
}
parallel = [] if sys.platform.startswith("win32") else ["--numprocesses=auto"]

session.create_tmp() # Fixes permission errors on Windows
session.install(*PYPROJECT["dependency-groups"]["test"], "uv")
session.install("-e.[tox_to_nox,pbs]")
extra_env = {"PYTHONWARNDEFAULTENCODING": "1"}
session.run("coverage", "erase", env=env)
session.run(
"coverage",
"run",
"-m",
"pytest",
"--cov",
"--cov-config",
"pyproject.toml",
"--cov-report=",
*parallel,
"-m",
"not conda",
*session.posargs,
env={
"COVERAGE_FILE": coverage_file,
**extra_env,
},
env=env,
)

if sys.platform.startswith("win"):
with contextlib.closing(sqlite3.connect(coverage_file)) as con, con:
con.execute("UPDATE file SET path = REPLACE(path, '\\', '/')")
con.execute("DELETE FROM file WHERE SUBSTR(path, 2, 1) == ':'")
session.run("coverage", "combine", env=env)
session.run("coverage", "report", env=env)


@nox.session(venv_backend="uv", default=False)
Expand All @@ -75,45 +74,54 @@ def minimums(session: nox.Session) -> None:

session.install("-e.", "--group=test", "--resolution=lowest-direct")
session.run("uv", "pip", "list")
session.run("pytest", *session.posargs)
session.run("pytest", "-m", "not conda", *session.posargs)


@nox.session(venv_backend="conda", default=bool(shutil.which("conda")))
def conda_tests(session: nox.Session) -> None:
"""Run test suite set up with conda."""
def xonda_tests(session: nox.Session, xonda: str) -> None:
"""Run test suite set up with conda/mamba/etc."""

coverage_file = f".coverage.{xonda}.{sys.platform}.{session.python}"
env = {"COVERAGE_FILE": coverage_file}

session.conda_install(
"--file", "requirements-conda-test.txt", channel="conda-forge"
)
session.install("-e.", "--no-deps")
# Currently, this doesn't work on Windows either with or without quoting
if not sys.platform.startswith("win32"):
session.conda_install("requests<99")
session.run("pytest", *session.posargs)

session.run("coverage", "erase", env=env)
session.run(
"coverage",
"run",
"-m",
"pytest",
"-m",
"conda",
*session.posargs,
env=env,
)
session.run("coverage", "combine", env=env)
session.run("coverage", "report", env=env)


@nox.session(venv_backend="conda", default=bool(shutil.which("conda")))
def conda_tests(session: nox.Session) -> None:
"""Run test suite set up with conda."""
xonda_tests(session, "conda")


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


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


@nox.session(default=False)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ test = [
"coverage[toml]>=7.10.3",
"pytest>=7.4; python_version>='3.12'",
"pytest>=7; python_version<'3.12'",
"pytest-cov>=3",
"pytest-xdist>=3",
]
docs = [
"myst-parser",
Expand Down
1 change: 1 addition & 0 deletions requirements-conda-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ humanize
jinja2
pbs-installer>=2025.1.6
pytest
pytest-xdist
tox>=4.0.0
virtualenv >=20.14.1
zstandard
Loading