Skip to content

Commit f5ee878

Browse files
authored
Add tox for easy testing of multiple Python versions (#100)
1 parent ac9d13a commit f5ee878

File tree

5 files changed

+52
-9
lines changed

5 files changed

+52
-9
lines changed

.coveragerc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# .coveragerc to control coverage.py
2+
3+
[report]
4+
# Regexes for lines to exclude from consideration
5+
exclude_also =
6+
# Don't complain if non-runnable code isn't run:
7+
if __name__ == .__main__.:

.github/workflows/tests.yml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,33 @@ jobs:
2020
exclude:
2121
# TODO Add Windows when regex wheel available for 3.13
2222
- {os: windows-latest, python-version: "3.13"}
23+
2324
steps:
24-
- uses: actions/checkout@v3
25+
- uses: actions/checkout@v4
26+
2527
- name: Set up Python ${{ matrix.python-version }}
2628
uses: actions/setup-python@v4
2729
with:
2830
python-version: ${{ matrix.python-version }}
2931
allow-prereleases: true
3032
cache: pip
3133
cache-dependency-path: .github/workflows/tests.yml
32-
- name: Upgrade pip
33-
run: python -m pip install --upgrade pip
34-
- name: Install pytest
35-
run: python -m pip install --upgrade pytest
36-
- name: Install sphinx-lint to pull dependencies
37-
run: python -m pip install -v .
34+
35+
- name: Install dependencies
36+
run: |
37+
python -m pip install -U pip
38+
python -m pip install -U wheel
39+
python -m pip install -U tox
40+
3841
- name: Download more tests from friend projects
3942
if: matrix.python-version == '3.13' && matrix.os == 'ubuntu-latest'
4043
run: sh download-more-tests.sh
41-
- name: run tests
42-
run: python -m pytest
44+
- name: Tox tests
45+
run: |
46+
tox -e py
47+
48+
- name: Upload coverage
49+
uses: codecov/codecov-action@v3
50+
with:
51+
flags: ${{ matrix.os }}
52+
name: ${{ matrix.os }} Python ${{ matrix.python-version }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ build/
22
dist/
33
__pycache__/
44
*.egg-info/
5+
.coverage
56
.envrc
67
.tox/
78
.venv/
89
tests/fixtures/friends/
10+
coverage.xml

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ dependencies = [
3030
dynamic = ["version"]
3131

3232

33+
[project.optional-dependencies]
34+
tests = [
35+
"pytest",
36+
"pytest-cov",
37+
]
3338
[project.urls]
3439
Repository = "https://github.com/sphinx-contrib/sphinx-lint"
3540
Changelog = "https://github.com/sphinx-contrib/sphinx-lint/releases"

tox.ini

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[tox]
2+
requires =
3+
tox>=4.2
4+
env_list =
5+
py{py3, 313, 312, 311, 310, 39, 38}
6+
7+
[testenv]
8+
extras =
9+
tests
10+
pass_env =
11+
FORCE_COLOR
12+
commands =
13+
{envpython} -m pytest \
14+
--cov sphinxlint \
15+
--cov tests \
16+
--cov-report html \
17+
--cov-report term \
18+
--cov-report xml \
19+
{posargs}

0 commit comments

Comments
 (0)