Skip to content

Commit

Permalink
Add coverage reporting to the test suite (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtmckee authored Sep 24, 2024
1 parent 878e195 commit de66430
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
run: pip install tox
- name: Run tox
# Run tox using the version of Python in `PATH`
run: tox -e py
run: tox -e py,coverage_report-ci

dist:
runs-on: ubuntu-latest
Expand Down
28 changes: 28 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,31 @@ build-backend = "setuptools.build_meta"
[tool.setuptools_scm]
write_to = "flask_compress/_version.py"
write_to_template = "__version__ = \"{version}\"\n"


# coverage
# --------

[tool.coverage.run]
relative_files = true
parallel = true
branch = true
source = [
"flask_compress",
"tests",
]

[tool.coverage.paths]
source = [
"flask_compress",
"*/site-packages",
]

[tool.coverage.report]
skip_covered = true
fail_under = 94


[tool.coverage.html]
directory = "htmlcov/"
skip_covered = false
32 changes: 31 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,15 +1,45 @@
[tox]
skip_missing_interpreters = true
envlist =
coverage_erase
# When modifying the list of CPython and PyPy versions to test here,
# be sure to update the "depends" configurations elsewhere in this file.
# This ensures that coverage is reported only after all tests have run.
py{39, 310, 311, 312}
pypy{39, 310}
coverage_report

[testenv:coverage_erase]
description = Erase coverage files
deps =
coverage[toml]
commands =
- coverage erase

[testenv]
description = Run the test suite
depends =
py{39, 310, 311, 312},pypy{39, 310}: coverage_erase
package = wheel
wheel_build_env = .pkg
deps =
coverage[toml]
pytest
commands = py.test {posargs}
commands =
coverage run -m pytest {posargs}

[testenv:coverage_report{,-ci}]
description = Generate HTML and console coverage reports
depends =
py{39, 310, 311, 312},pypy{39, 310}
deps =
coverage[toml]
commands_pre =
- coverage combine
# Only generate an HTML coverage report when running locally.
!ci: - coverage html
commands =
coverage report

[flake8]
max-line-length = 88
Expand Down

0 comments on commit de66430

Please sign in to comment.