Skip to content

Commit cf6f6ad

Browse files
BenjaminBossanrwightman
authored andcommitted
Add pytest-cov, requirements-dev, pyproject.toml
When tests finish, a report should be printed that shows the code coverage of timm. This should give us a better idea where we should work on test coverage. I have tested this locally (on a subset of tests) and it worked. Since the number of test dependencies was getting quite high, I created a requirements-dev.txt and moved them there. GH action and CONTRIBUTING.md are adjusted accordingly. Furthermore, instead of extending the pytest invocation, I created a pyproject.toml and added the coverage options there. For completeness, I also added the black settings that come closest to the style of timm. LMK if this is not desired. For now, the coverage is only reported but not enforced. I.e. when a PR is created that adds uncovered lines, CI will still succeed. We could think about adding codecov or something like that, but it can be annoying sometimes and the service was flaky for me in the past.
1 parent a5b01ec commit cf6f6ad

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Install testing dependencies
3131
run: |
3232
python -m pip install --upgrade pip
33-
pip install pytest pytest-timeout pytest-xdist pytest-forked expecttest
33+
pip install -r requirements-dev.txt
3434
- name: Install torch on mac
3535
if: startsWith(matrix.os, 'macOS')
3636
run: pip install --no-cache-dir torch==${{ matrix.torch }} torchvision==${{ matrix.torchvision }}

CONTRIBUTING.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,13 @@ There are a LOT of gaps in current documentation relative to the functionality i
7373

7474
# Installation
7575

76-
Create a Python virtual environment using Python 3.10. Inside the environment, install the following test dependencies:
77-
78-
```
79-
python -m pip install pytest pytest-timeout pytest-xdist pytest-forked expecttest
80-
```
81-
82-
Install `torch` and `torchvision` using the instructions matching your system as listed on the [PyTorch website](https://pytorch.org/).
76+
Create a Python virtual environment using Python 3.10. Inside the environment, install torch` and `torchvision` using the instructions matching your system as listed on the [PyTorch website](https://pytorch.org/).
8377

8478
Then install the remaining dependencies:
8579

8680
```
8781
python -m pip install -r requirements.txt
82+
python -m pip install -r requirements-dev.txt # for testing
8883
python -m pip install --no-cache-dir git+https://github.com/mapillary/inplace_abn.git
8984
python -m pip install -e .
9085
```

pyproject.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[tool.pytest.ini_options]
2+
addopts = "--cov=timm --cov-report=term-missing"
3+
4+
[tool.coverage.run]
5+
omit = [
6+
"tests/test_*.py",
7+
]
8+
9+
[tool.black]
10+
line-length = 120
11+
target-version = ['py37', 'py38', 'py39', 'py310', 'py311']
12+
skip-string-normalization = true

requirements-dev.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pytest
2+
pytest-timeout
3+
pytest-xdist
4+
pytest-forked
5+
expecttest
6+
pytest-cov

0 commit comments

Comments
 (0)