-
Notifications
You must be signed in to change notification settings - Fork 0
/
noxfile.py
99 lines (74 loc) · 2.49 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
"""Run tests using Nox
Quick Usage
-----------
```
pdm run nox -s <SESSION_NAME>-<VERSION>
```
Description
-----------
You have options on how to use Nox depending on which applications are on your platform. If you have all supported
Python versions installed and in your $PATH, then you can use the `noxfile.test` method like so
```
pdm run nox -s tests_venv # Or
pdm run nox -s tests_virtualenv
```
If you have a limited installation set, you can install the Anaconda, Mamba, or micromamba and run
```
pdm run nox -s tests_conda # Or
pdm run nox -s tests_mamba # Or
pdm run nox -s tests_micromamba
```
"""
from pathlib import Path
import nox
import os
os.environ.update({"PDM_IGNORE_SAVED_PYTHON": "1"})
supported_pythons = ["3.9", "3.10", "3.11", "3.12"]
@nox.session(
python=supported_pythons,
venv_backend="venv"
)
def tests_venv(session: nox.Session) -> None:
"""Test environment the venv venv_backend"""
_pdm_install_test_group(session)
_unifed_test(session)
@nox.session(
python=supported_pythons,
venv_backend="virtualenv"
)
def tests_virtualenv(session: nox.Session) -> None:
"""Test environment the virtualenv venv_backend"""
_pdm_install_test_group(session)
_unifed_test(session)
@nox.session(
python=supported_pythons,
venv_backend="conda",
)
def tests_conda(session: nox.Session) -> None:
"""Test environment with the conda venv_backend"""
_tests_conda_like(session)
@nox.session(
python=supported_pythons,
venv_backend="micromamba",
)
def tests_micromamba(session: nox.Session) -> None:
"""Test environment with the micromamba venv_backend"""
_tests_conda_like(session)
@nox.session(
python=supported_pythons,
venv_backend="mamba",
)
def tests_mamba(session: nox.Session) -> None:
"""Test environment with the mamba venv_backend"""
_tests_conda_like(session)
def _pdm_install_test_group(session: nox.Session) -> None:
session.run_always("pdm", "install", "-dG", "test", external=True)
def _tests_conda_like(session: nox.Session) -> None:
session.run_always("pdm", "build", external=True)
session.install("--upgrade", "pip")
session.run_always("pip", "install", "-f", os.fspath(Path.cwd() / "dist"), "envector")
session.install("pytest", "pytest-cov", "pytest-pep8", "hypothesis")
_unifed_test(session)
def _unifed_test(session: nox.Session) -> None:
"""The unified command to run the test suite"""
session.run("pytest", "-rxsXf", "--doctest-modules", "src", "tests")