From de664300d1bfdc53b032d719023a44a4b4f99ab3 Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Tue, 24 Sep 2024 14:48:07 -0500 Subject: [PATCH] Add coverage reporting to the test suite (#52) --- .github/workflows/ci.yaml | 2 +- pyproject.toml | 28 ++++++++++++++++++++++++++++ tox.ini | 32 +++++++++++++++++++++++++++++++- 3 files changed, 60 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f241afd..873d1ab 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 5e4d3f8..0154742 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 diff --git a/tox.ini b/tox.ini index ac39dd0..2235b3c 100644 --- a/tox.ini +++ b/tox.ini @@ -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