-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoxfile.py
69 lines (58 loc) · 1.94 KB
/
noxfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
"""Nox sessions."""
import os
from pathlib import Path
import nox
from nox_poetry import Session
from nox_poetry import session
package = "citrus"
python_versions = ["3.11", "3.12"]
nox.needs_version = ">= 2022.11.21"
nox.options.sessions = (
"tests",
)
cov_cli_args = [
"--cov=.",
"--cov-report=term-missing",
]
def install_handle_python(session):
"""
handle incompatibilities between python and other packages
see https://github.com/cjolowicz/nox-poetry/issues/1116
"""
# install the latest versions of all dependencies for py3.9+
# but install the locked versions for < py3.9 to ensure some stability in the CI and
# help us understand when we need to bump our version constraints
if session._session.python in ("3.9", "3.10", "3.11", "3.12"):
session._session.install(".")
else:
session.install(".")
# detect whether conda/mamba is installed
if os.getenv("CONDA_EXE"):
conda_cmd = "conda"
if (Path(os.getenv("CONDA_EXE")).parent / "mamba").exists():
conda_cmd = "mamba"
conda_args = ["-c", "conda-forge"]
@session(venv_backend=conda_cmd, venv_params=conda_args, python=python_versions)
def tests(session: Session) -> None:
"""Run the test suite."""
session.conda_install(
"numpy",
"pytest",
"pytest-cov",
channel="conda-forge",
)
install_handle_python(session)
session.run(
"python", "-m", "pytest", *cov_cli_args, *session.posargs
)
session.run("./test/cmdline_tests.sh", external=True)
else:
@session(python=python_versions)
def tests(session: Session) -> None:
"""Run the test suite."""
session.install("pytest", "pytest-cov")
install_handle_python_numpy(session)
session.run(
"python", "-m", "pytest", *cov_cli_args, *session.posargs
)
session.run("./test/cmdline_tests.sh", external=True)