Skip to content

Commit

Permalink
Ignore conftest.py in code coverage
Browse files Browse the repository at this point in the history
In addition, make it easier for produce coverage report locally by
adding pytest config options to pyproject.toml. This also produces
consistent results between local runs and runs in CI, and adds a
term-missing report for human readability, both for local runs as well
as in CI, so it show up in the logs.

Fixes #387
  • Loading branch information
chuckwondo committed Jan 24, 2025
1 parent e3787c5 commit 5fd282c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
omit =
virtualizarr/tests/*
3 changes: 2 additions & 1 deletion .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ coverage:
project:
default:
target: 75
threshold: 0.1
# See https://json.schemastore.org/codecov.json
threshold: "0.1%"
patch:
default:
target: 75
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Running Tests
run: |
python -m pytest ./virtualizarr --run-network-tests --cov=./ --cov-report=xml --verbose
python -m pytest --run-network-tests --cov-report=xml --verbose virtualizarr
- name: Upload code coverage to Codecov
uses: codecov/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/min-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Running Tests
run: |
python -m pytest ./virtualizarr --cov=./ --cov-report=xml --verbose
python -m pytest --cov-report=xml --verbose virtualizarr
- name: Upload code coverage to Codecov
uses: codecov/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Running Tests
run: |
python -m pytest ./virtualizarr --cov=./ --cov-report=xml --verbose
python -m pytest --cov-report=xml --verbose virtualizarr
- name: Upload code coverage to Codecov
uses: codecov/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ mamba activate virtualizarr-tests
pre-commit install
# git checkout -b new-feature
python -m pip install -e . --no-deps
python -m pytest ./virtualizarr --run-network-tests --cov=./ --cov-report=xml --verbose
python -m pytest --run-network-tests
```

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.
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.

## Contributing documentation

Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ line-ending = "auto"
known-first-party = ["virtualizarr"]

[tool.pytest.ini_options]
addopts = [
"--cov=virtualizarr",
"--cov-report=term-missing",
]
markers = [
"network: marks test requiring internet (select with '--run-network-tests')",
]

0 comments on commit 5fd282c

Please sign in to comment.