From 61fbaad4a7f85fd752799c45ed1fe2021c2bec88 Mon Sep 17 00:00:00 2001 From: John Gardner <92588218+jla-gardner@users.noreply.github.com> Date: Wed, 17 Jul 2024 07:53:13 +0100 Subject: [PATCH] fix `coverage` (#23) --- .github/workflows/tests.yaml | 2 +- pyproject.toml | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 59631dbb..8a151531 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -46,7 +46,7 @@ jobs: - name: Useful info run: pip freeze - name: Run tests - run: pytest --cov src --cov-report xml + run: pytest --cov --cov-report xml - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 # only upload coverage reports for the first python version diff --git a/pyproject.toml b/pyproject.toml index e34e8276..e753a3db 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -96,6 +96,16 @@ exclude_also = [ "if __name__ == '__main__':", ] +# allow for coverage to find relevant files in both src/ and */site-packages +# so that we can install the package both normally and in editable mode, and +# still get coverage for both cases using `pytest --cov` +[tool.coverage.paths] +source = ["src", "*/site-packages"] + +[tool.coverage.run] +branch = true +source = ["graph_pes"] + [tool.pytest.ini_options] # ignore all warnings coming from the pytorch_lightning package filterwarnings = [