From a3249c645c2be33d67abf10f3803a7dbeeb972a1 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Tue, 29 Apr 2025 10:02:56 +0300 Subject: [PATCH 1/2] Test with coverage --- .github/workflows/build.yml | 16 +++++++++++++--- README.md | 2 ++ pyproject.toml | 14 +++++++++++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0c7fc70..b2b6ea9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,8 +3,9 @@ name: 'Build and Test' on: [push, pull_request, workflow_dispatch] env: + COVERAGE_CORE: sysmon + FORCE_COLOR: 1 PIP_DISABLE_PIP_VERSION_CHECK: true - PIP_NO_COLOR: true PIP_NO_INPUT: true PIP_PROGRESS_BAR: off PIP_REQUIRE_VIRTUALENV: false @@ -38,13 +39,22 @@ jobs: run: python -m pip install pymsbuild - name: 'Install test runner' - run: python -m pip install pytest + run: python -m pip install pytest pytest-cov - name: 'Build test module' run: python -m pymsbuild -c _msbuild_test.py - name: 'Run pre-test' - run: python -m pytest -vv + shell: bash + run: | + python -m pytest -vv \ + --cov src \ + --cov tests \ + --cov-report term \ + --cov-report xml + + - name: 'Upload coverage' + uses: codecov/codecov-action@v5 - name: 'Build package' run: python make.py diff --git a/README.md b/README.md index 3e75507..6d54411 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Python Install Manager +[![Codecov](https://codecov.io/gh/python/pymanager/graph/badge.svg)](https://codecov.io/gh/python/pymanager) + This is the source code for the Python Install Manager app. For information about how to use the Python install manager, diff --git a/pyproject.toml b/pyproject.toml index 62c1fde..e4d9bdb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,15 @@ [build-system] requires = ['pymsbuild>=1.1.1,<2.0'] -build-backend = "pymsbuild" \ No newline at end of file +build-backend = "pymsbuild" + +[tool.coverage.run] +branch = true +disable_warnings = [ + "no-sysmon", +] +omit = [ + "src/manage/__main__.py", +] + +[tool.coverage.html] +show_contexts = true From e95569aa55fc22c7084ab5881fc0661b8f7130e2 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Tue, 29 Apr 2025 11:29:08 +0300 Subject: [PATCH 2/2] Fix shadowed and non-run test --- tests/test_installs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_installs.py b/tests/test_installs.py index 0b809ae..48e007d 100644 --- a/tests/test_installs.py +++ b/tests/test_installs.py @@ -120,7 +120,7 @@ def test_get_install_to_run_with_platform(patched_installs): assert i["executable"].match("python.exe") -def test_get_install_to_run_with_platform(patched_installs): +def test_get_install_to_run_with_platform_windowed(patched_installs): i = installs.get_install_to_run("", None, "1.0-32", windowed=True) assert i["id"] == "PythonCore-1.0-32" assert i["executable"].match("pythonw.exe")