Skip to content

Commit 97f91b5

Browse files
authored
test: Speeds up test suite using plugins (#222)
* chore: Updates pytest * docs: Updates makefile * ci: Updates CI * ci: Updates codecov upload * ci: Adds multiple builds * ci: Fixes CI version * style: Bumps mypy * chore: Python 3.12 isn't supported yet * ci: Reverts back
1 parent 0d7a579 commit 97f91b5

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

.github/workflows/style.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
architecture: x64
2323
- name: Run ruff
2424
run: |
25-
pip install ruff
25+
pip install ruff==0.1.0
2626
ruff --version
2727
ruff check --diff .
2828
@@ -47,8 +47,7 @@ jobs:
4747
- name: Install dependencies
4848
run: |
4949
python -m pip install --upgrade pip
50-
pip install -e . --upgrade
51-
pip install "mypy==1.4.1"
50+
pip install -e ".[quality]" --upgrade
5251
- name: Run mypy
5352
run: |
5453
mypy --version

.github/workflows/tests.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ jobs:
3232
python -m pip install --upgrade pip
3333
pip install -e ".[test]" --upgrade
3434
- name: Run unittests
35-
run: |
36-
coverage run -m pytest tests/
37-
coverage xml
35+
run: pytest --cov=torchcam --cov-report xml tests/ -n auto
3836
- uses: actions/upload-artifact@v2
3937
with:
4038
name: coverage-main
@@ -44,11 +42,10 @@ jobs:
4442
runs-on: ubuntu-latest
4543
needs: pytest
4644
steps:
47-
- uses: actions/checkout@v2
4845
- uses: actions/download-artifact@v2
49-
- name: Upload coverage to Codecov
50-
uses: codecov/codecov-action@v1
46+
- uses: codecov/codecov-action@v3
5147
with:
48+
token: ${{ secrets.CODECOV_TOKEN }}
5249
flags: unittests
5350
fail_ci_if_error: true
5451

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ style:
1212

1313
# Run tests for the library
1414
test:
15-
coverage run -m pytest tests/
15+
pytest --cov=torchcam tests/ -n auto
1616

1717
# Build documentation for current version
1818
single-docs:

pyproject.toml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,16 @@ dependencies = [
4242

4343
[project.optional-dependencies]
4444
test = [
45-
"pytest>=5.3.2",
46-
"coverage[toml]>=4.5.4",
4745
"requests>=2.20.0,<3.0.0",
4846
"torchvision>=0.15.0,<1.0.0",
47+
"pytest>=7.3.2",
48+
"pytest-cov>=3.0.0,<5.0.0",
49+
"pytest-xdist>=2.0.0,<4.0.0",
50+
"pytest-pretty>=1.0.0,<2.0.0",
4951
]
5052
quality = [
51-
"ruff>=0.0.290,<1.0.0",
52-
"mypy==1.4.1",
53+
"ruff==0.1.0",
54+
"mypy==1.5.1",
5355
"black==23.3.0",
5456
"bandit[toml]>=1.7.0,<1.8.0",
5557
"pre-commit>=2.17.0,<3.0.0",
@@ -71,13 +73,15 @@ demo = [
7173
]
7274
dev = [
7375
# test
74-
"pytest>=5.3.2",
75-
"coverage[toml]>=4.5.4",
7676
"requests>=2.20.0,<3.0.0",
7777
"torchvision>=0.15.0,<1.0.0",
78+
"pytest>=7.3.2",
79+
"pytest-cov>=4.0.0,<5.0.0",
80+
"pytest-xdist>=3.0.0,<4.0.0",
81+
"pytest-pretty>=1.0.0,<2.0.0",
7882
# style
79-
"ruff>=0.0.290,<1.0.0",
80-
"mypy==1.4.1",
83+
"ruff==0.1.0",
84+
"mypy==1.5.1",
8185
"black==23.3.0",
8286
"bandit[toml]>=1.7.0,<1.8.0",
8387
"pre-commit>=2.17.0,<3.0.0",
@@ -103,8 +107,8 @@ zip-safe = true
103107
[tool.setuptools.packages.find]
104108
exclude = ["demo*", "docs*", "notebooks*", "scripts*", "tests*"]
105109

106-
[tool.coverage.run]
107-
source = ["torchcam"]
110+
[tool.pytest.ini_options]
111+
testpaths = ["torchcam/"]
108112

109113
[tool.ruff]
110114
select = [

0 commit comments

Comments
 (0)