Skip to content

Commit a1f0005

Browse files
authored
Switch to nox for automated testing (pypa#212)
1 parent 5d27795 commit a1f0005

File tree

4 files changed

+59
-49
lines changed

4 files changed

+59
-49
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
with:
2121
python-version: ${{ matrix.python }}
2222
- name: Install test dependencies
23-
run: python -m pip install -U tox
23+
run: python -m pip install --upgrade nox
2424
- name: Test
25-
run: python -m tox -e py
25+
run: python -m nox -s tests-${{ matrix.python }}
26+
- name: Lint
27+
run: python -m nox -s lint

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ dist/
77
__pycache__/
88
*.so
99
*~
10+
venv/
1011

11-
# due to using tox and pytest
12-
.tox
12+
# due to using nox and pytest
13+
.nox
1314
.cache

noxfile.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# this file is *not* meant to cover or endorse the use of nox or pytest or
2+
# testing in general,
3+
#
4+
# It's meant to show the use of:
5+
#
6+
# - check-manifest
7+
# confirm items checked into vcs are in your sdist
8+
# - readme_renderer (when using a reStructuredText README)
9+
# confirms your long_description will render correctly on PyPI.
10+
#
11+
# and also to help confirm pull requests to this project.
12+
13+
import nox
14+
import os
15+
16+
nox.options.sessions = ["lint"]
17+
18+
# Define the minimal nox version required to run
19+
nox.options.needs_version = ">= 2024.3.2"
20+
21+
22+
@nox.session
23+
def lint(session):
24+
session.install("flake8")
25+
session.run(
26+
"flake8", "--exclude", ".nox,*.egg,build,data",
27+
"--select", "E,W,F", "."
28+
)
29+
30+
31+
@nox.session
32+
def build_and_check_dists(session):
33+
session.install("build", "check-manifest >= 0.42", "twine")
34+
# If your project uses README.rst, uncomment the following:
35+
# session.install("readme_renderer")
36+
37+
session.run("check-manifest", "--ignore", "noxfile.py,tests/**")
38+
session.run("python", "-m", "build")
39+
session.run("python", "-m", "twine", "check", "dist/*")
40+
41+
42+
@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12"])
43+
def tests(session):
44+
session.install("pytest")
45+
build_and_check_dists(session)
46+
47+
generated_files = os.listdir("dist/")
48+
generated_sdist = os.path.join("dist/", generated_files[1])
49+
50+
session.install(generated_sdist)
51+
52+
session.run("py.test", "tests/", *session.posargs)

tox.ini

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)