Skip to content

Commit 443928f

Browse files
authored
Ignore conftest.py in code coverage (#388)
* Ignore conftest.py in code coverage * Configure coverage in pyproject.toml * Do not run pytest coverage by default
1 parent e8ade46 commit 443928f

File tree

9 files changed

+35
-9
lines changed

9 files changed

+35
-9
lines changed

.github/codecov.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ coverage:
33
project:
44
default:
55
target: 75
6-
threshold: 0.1
6+
# See https://json.schemastore.org/codecov.json
7+
threshold: "0.1%"
78
patch:
89
default:
910
target: 75
@@ -14,4 +15,5 @@ comment:
1415
branches: # branch names that can post comment
1516
- "main"
1617
ignore:
18+
- "conftest.py"
1719
- "virtualizarr/tests" # ignore folders and all its contents

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
5252
- name: Running Tests
5353
run: |
54-
python -m pytest ./virtualizarr --run-network-tests --cov=./ --cov-report=xml --verbose
54+
python -m pytest --run-network-tests --verbose --cov=virtualizarr --cov-report=xml
5555
5656
- name: Upload code coverage to Codecov
5757
uses: codecov/[email protected]

.github/workflows/min-deps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
5252
- name: Running Tests
5353
run: |
54-
python -m pytest ./virtualizarr --cov=./ --cov-report=xml --verbose
54+
python -m pytest --verbose --cov=virtualizarr --cov-report=xml
5555
5656
- name: Upload code coverage to Codecov
5757
uses: codecov/[email protected]

.github/workflows/upstream.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
5252
- name: Running Tests
5353
run: |
54-
python -m pytest ./virtualizarr --cov=./ --cov-report=xml --verbose
54+
python -m pytest --verbose --cov=virtualizarr --cov-report=xml
5555
5656
- name: Upload code coverage to Codecov
5757
uses: codecov/[email protected]

ci/environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencies:
1616
- hdf5plugin
1717
- numcodecs
1818
# Testing
19-
- codecov
19+
- codecov[toml]
2020
- pre-commit
2121
- mypy
2222
- ruff

ci/min-deps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies:
1313
- ujson
1414
- universal_pathlib
1515
# Testing
16-
- codecov
16+
- codecov[toml]
1717
- pre-commit
1818
- mypy
1919
- ruff

ci/upstream.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencies:
1616
- numcodecs
1717
- imagecodecs>=2024.6.1
1818
# Testing
19-
- codecov
19+
- codecov[toml]
2020
- pre-commit
2121
- mypy
2222
- ruff

docs/contributing.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,30 @@ mamba activate virtualizarr-tests
1212
pre-commit install
1313
# git checkout -b new-feature
1414
python -m pip install -e . --no-deps
15-
python -m pytest ./virtualizarr --run-network-tests --cov=./ --cov-report=xml --verbose
15+
python -m pytest
1616
```
1717

18-
The `--run-network-tests` argument is optional - it will run additional tests that require downloading files over the network. Skip this if you want the tests to run faster or you have no internet access.
18+
You may also add the `--run-network-tests` option, which will run additional tests
19+
that require downloading files over the network. Skip this if you want the tests to run
20+
faster or you have no internet access:
21+
22+
```bash
23+
python -m pytest --run-network-tests
24+
```
25+
26+
Further, the `pytest-cov` plugin is a test dependency, so you can generate a test
27+
coverage report locally, if you wish (CI will automatically do so). Here are some
28+
examples:
29+
30+
```bash
31+
python -m pytest --cov=. # Terminal (text) report (--cov=term)
32+
python -m pytest --cov=. --cov=term-missing # Terminal report showing missing coverage
33+
python -m pytest --cov=. --cov=html # HTML report written to htmlcov/index.html
34+
```
35+
36+
To see all available `pytest` options added by the `pytest-cov` plugin, run
37+
`python -m pytest -h`, or see the
38+
[pytest-cov documentation](https://pytest-cov.readthedocs.io/en/latest/readme.html).
1939

2040
## Contributing documentation
2141

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ line-ending = "auto"
148148
[tool.ruff.lint.isort]
149149
known-first-party = ["virtualizarr"]
150150

151+
[tool.coverage.run]
152+
include = ["virtualizarr/"]
153+
omit = ["conftest.py", "virtualizarr/tests/*"]
154+
151155
[tool.pytest.ini_options]
152156
# See https://pytest-asyncio.readthedocs.io/en/latest/concepts.html#asyncio-event-loops
153157
# Explicitly set asyncio_default_fixture_loop_scope to eliminate the following warning:

0 commit comments

Comments
 (0)