Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: nedbat/coveragepy
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7.6.12
Choose a base ref
...
head repository: nedbat/coveragepy
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7.7.0
Choose a head ref

Commits on Feb 11, 2025

  1. build: bump version to 7.6.13

    nedbat committed Feb 11, 2025
    Copy the full SHA
    150f8a9 View commit details

Commits on Feb 14, 2025

  1. Copy the full SHA
    830d2eb View commit details

Commits on Feb 15, 2025

  1. Copy the full SHA
    1bf0db2 View commit details
  2. fix: better understanding of constant conditions

    nedbat committed Feb 15, 2025
    Copy the full SHA
    3e87fab View commit details

Commits on Feb 16, 2025

  1. feature: provide an API for passing plugin objects to the Coverage co…

    …nstructor (#1919)
    alex authored Feb 16, 2025
    Copy the full SHA
    ad7daf6 View commit details
  2. refactor: re-organize plugin construction. #1919

    Also simplify the callable signature for plugin overrides, since the
    second config argument would always be empty.
    nedbat committed Feb 16, 2025
    Copy the full SHA
    bca4272 View commit details
  3. refactor: check_coverage now uses keyword-only arguments

    nedbat committed Feb 16, 2025
    Copy the full SHA
    f34a510 View commit details
  4. tests: remove some multi-lines options that aren't needed anymore

    nedbat committed Feb 16, 2025
    Copy the full SHA
    7e94883 View commit details

Commits on Feb 17, 2025

  1. chore: make upgrade

    nedbat committed Feb 17, 2025
    Copy the full SHA
    6ec7859 View commit details
  2. build: pandoc bug fix is now available

    jgm/pandoc#10497 meant I needed a local
    installation of pandoc, but it's fixed in homebrew now, so all is well.
    That `_decimal` thing was different between the versions, so get rid of
    it.
    nedbat committed Feb 17, 2025
    Copy the full SHA
    d1ba6db View commit details

Commits on Feb 20, 2025

  1. test: PyPy3.11 test fixes (#1929)

    * test: Fix expected exception message for PyPy3.11
    
    Fix the regex in `test_parser.py::PythonParserTest::test_not_python`
    to account for the possibility of code being wrapped in double quotes
    rather than single quotes, to fix the test on PyPy3.11.
    
    * test: Skip CTracer tests on pypy311 too
    mgorny authored Feb 20, 2025
    Copy the full SHA
    a311706 View commit details
  2. docs: mention PyPy 3.11 support

    nedbat committed Feb 20, 2025
    Copy the full SHA
    1aecfa7 View commit details

Commits on Mar 3, 2025

  1. chore: bump the action-dependencies group with 4 updates (#1931)

    Bumps the action-dependencies group with 4 updates: [github/codeql-action](https://github.com/github/codeql-action), [actions/upload-artifact](https://github.com/actions/upload-artifact), [actions/download-artifact](https://github.com/actions/download-artifact) and [actions/attest-build-provenance](https://github.com/actions/attest-build-provenance).
    
    
    Updates `github/codeql-action` from 3.28.9 to 3.28.10
    - [Release notes](https://github.com/github/codeql-action/releases)
    - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
    - [Commits](github/codeql-action@9e8d078...b56ba49)
    
    Updates `actions/upload-artifact` from 4.6.0 to 4.6.1
    - [Release notes](https://github.com/actions/upload-artifact/releases)
    - [Commits](actions/upload-artifact@65c4c4a...4cec3d8)
    
    Updates `actions/download-artifact` from 4.1.8 to 4.1.9
    - [Release notes](https://github.com/actions/download-artifact/releases)
    - [Commits](actions/download-artifact@fa0a91b...cc20338)
    
    Updates `actions/attest-build-provenance` from 2.2.0 to 2.2.2
    - [Release notes](https://github.com/actions/attest-build-provenance/releases)
    - [Changelog](https://github.com/actions/attest-build-provenance/blob/main/RELEASE.md)
    - [Commits](actions/attest-build-provenance@520d128...bd77c07)
    
    ---
    updated-dependencies:
    - dependency-name: github/codeql-action
      dependency-type: direct:production
      update-type: version-update:semver-patch
      dependency-group: action-dependencies
    - dependency-name: actions/upload-artifact
      dependency-type: direct:production
      update-type: version-update:semver-patch
      dependency-group: action-dependencies
    - dependency-name: actions/download-artifact
      dependency-type: direct:production
      update-type: version-update:semver-patch
      dependency-group: action-dependencies
    - dependency-name: actions/attest-build-provenance
      dependency-type: direct:production
      update-type: version-update:semver-patch
      dependency-group: action-dependencies
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Mar 3, 2025
    Copy the full SHA
    6c5291a View commit details
  2. chore: make upgrade doc_upgrade

    nedbat committed Mar 3, 2025
    Copy the full SHA
    97ce68c View commit details

Commits on Mar 4, 2025

  1. refactor: improve warning suppression performance by using sets (#1932)

    * feat(performance): improve warning suppression lookup by using set
    
    * fix: initialize _no_warn_slugs as a empty set
    allrob23 authored Mar 4, 2025
    Copy the full SHA
    8c5a5ff View commit details

Commits on Mar 6, 2025

  1. clean up the warnings, some we don't need anymore

    nedbat committed Mar 6, 2025
    Copy the full SHA
    3418eb9 View commit details

Commits on Mar 9, 2025

  1. feat: sys.monitoring, switch from BRANCH_TAKEN to BRANCH_RIGHT

    Now branch measurement should be fast on 3.14.0a5+.  It is still not a
    default core, but we might be getting close.
    nedbat committed Mar 9, 2025
    Copy the full SHA
    2e88d42 View commit details
  2. test: benchmark tweaks

    Though it didn't result in a runnable benchmark :(
    nedbat committed Mar 9, 2025
    Copy the full SHA
    e3504b0 View commit details
  3. Copy the full SHA
    79c7fae View commit details
  4. style: fix one change from updated pylint

    nedbat committed Mar 9, 2025
    Copy the full SHA
    824b3ba View commit details

Commits on Mar 10, 2025

  1. chore: bump the action-dependencies group with 2 updates (#1935)

    Bumps the action-dependencies group with 2 updates: [github/codeql-action](https://github.com/github/codeql-action) and [actions/attest-build-provenance](https://github.com/actions/attest-build-provenance).
    
    
    Updates `github/codeql-action` from 3.28.10 to 3.28.11
    - [Release notes](https://github.com/github/codeql-action/releases)
    - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
    - [Commits](github/codeql-action@b56ba49...6bb031a)
    
    Updates `actions/attest-build-provenance` from 2.2.2 to 2.2.3
    - [Release notes](https://github.com/actions/attest-build-provenance/releases)
    - [Changelog](https://github.com/actions/attest-build-provenance/blob/main/RELEASE.md)
    - [Commits](actions/attest-build-provenance@bd77c07...c074443)
    
    ---
    updated-dependencies:
    - dependency-name: github/codeql-action
      dependency-type: direct:production
      update-type: version-update:semver-patch
      dependency-group: action-dependencies
    - dependency-name: actions/attest-build-provenance
      dependency-type: direct:production
      update-type: version-update:semver-patch
      dependency-group: action-dependencies
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Mar 10, 2025
    Copy the full SHA
    0973f44 View commit details

Commits on Mar 11, 2025

  1. test: benchmark improvements

    nedbat committed Mar 11, 2025
    Copy the full SHA
    c9908d7 View commit details
  2. perf(sysmon): improve speed

    Don't compute trails until we need them.  No logging.  Tweak the
    environment variables.
    nedbat committed Mar 11, 2025
    Copy the full SHA
    1e99d28 View commit details

Commits on Mar 14, 2025

  1. perf(sysmon): silly mistake

    nedbat committed Mar 14, 2025
    Copy the full SHA
    7e9f2f2 View commit details

Commits on Mar 15, 2025

  1. lint: somehow these snuck through

    nedbat committed Mar 15, 2025
    Copy the full SHA
    c4919cb View commit details

Commits on Mar 16, 2025

  1. Copy the full SHA
    33f12df View commit details
  2. docs: edit the changelog

    nedbat committed Mar 16, 2025
    Copy the full SHA
    8f6e006 View commit details
  3. docs: prep for 7.7.0

    nedbat committed Mar 16, 2025
    Copy the full SHA
    35a31c5 View commit details
  4. docs: sample HTML for 7.7.0

    nedbat committed Mar 16, 2025
    Copy the full SHA
    61dcf71 View commit details
Showing with 1,162 additions and 633 deletions.
  1. +3 −3 .github/workflows/codeql-analysis.yml
  2. +4 −4 .github/workflows/coverage.yml
  3. +6 −6 .github/workflows/kit.yml
  4. +4 −4 .github/workflows/publish.yml
  5. +8 −9 .github/workflows/testsuite.yml
  6. +29 −1 CHANGES.rst
  7. +1 −0 Makefile
  8. +3 −2 README.rst
  9. +9 −0 benchmark/README.rst
  10. +42 −3 benchmark/benchmark.py
  11. +9 −6 benchmark/run.py
  12. +1 −1 coverage/cmdline.py
  13. +38 −8 coverage/control.py
  14. +32 −20 coverage/core.py
  15. +5 −0 coverage/env.py
  16. +29 −20 coverage/parser.py
  17. +22 −20 coverage/plugin_support.py
  18. +1 −0 coverage/results.py
  19. +267 −124 coverage/sysmon.py
  20. +1 −1 coverage/version.py
  21. +15 −3 doc/cmd.rst
  22. +3 −3 doc/conf.py
  23. +2 −2 doc/index.rst
  24. +14 −8 doc/requirements.pip
  25. +4 −4 doc/sample_html/class_index.html
  26. +4 −4 doc/sample_html/function_index.html
  27. +4 −4 doc/sample_html/index.html
  28. +1 −1 doc/sample_html/status.json
  29. +4 −4 doc/sample_html/z_7b071bdc2a35fa80___init___py.html
  30. +4 −4 doc/sample_html/z_7b071bdc2a35fa80___main___py.html
  31. +4 −4 doc/sample_html/z_7b071bdc2a35fa80_cogapp_py.html
  32. +4 −4 doc/sample_html/z_7b071bdc2a35fa80_makefiles_py.html
  33. +4 −4 doc/sample_html/z_7b071bdc2a35fa80_test_cogapp_py.html
  34. +4 −4 doc/sample_html/z_7b071bdc2a35fa80_test_makefiles_py.html
  35. +4 −4 doc/sample_html/z_7b071bdc2a35fa80_test_whiteutils_py.html
  36. +4 −4 doc/sample_html/z_7b071bdc2a35fa80_utils_py.html
  37. +4 −4 doc/sample_html/z_7b071bdc2a35fa80_whiteutils_py.html
  38. +4 −1 igor.py
  39. +28 −23 lab/run_sysmon.py
  40. +1 −0 metacov.ini
  41. +7 −1 pyproject.toml
  42. +9 −9 requirements/dev.pip
  43. +4 −4 requirements/kit.pip
  44. +2 −2 requirements/light-threads.pip
  45. +4 −4 requirements/mypy.pip
  46. +2 −2 requirements/pip-tools.pip
  47. +2 −2 requirements/pip.pip
  48. +2 −2 requirements/pytest.pip
  49. +1 −1 requirements/tox.pip
  50. +6 −4 tests/conftest.py
  51. +26 −2 tests/coveragetest.py
  52. +12 −13 tests/gold/README.rst
  53. +1 −1 tests/gold/html/Makefile
  54. +6 −6 tests/gold/html/partial/class_index.html
  55. +6 −6 tests/gold/html/partial/function_index.html
  56. +6 −6 tests/gold/html/partial/index.html
  57. +4 −4 tests/gold/html/partial/partial_py.html
  58. +11 −11 tests/gold/html/partial_626/class_index.html
  59. +11 −11 tests/gold/html/partial_626/function_index.html
  60. +11 −11 tests/gold/html/partial_626/index.html
  61. +8 −8 tests/gold/html/partial_626/partial_py.html
  62. +19 −6 tests/test_api.py
  63. +47 −33 tests/test_arcs.py
  64. +11 −2 tests/test_concurrency.py
  65. +242 −127 tests/test_coverage.py
  66. +1 −1 tests/test_html.py
  67. +12 −8 tests/test_oddball.py
  68. +16 −14 tests/test_parser.py
  69. +31 −9 tests/test_plugins.py
  70. +10 −0 tests/test_process.py
  71. +2 −2 tox.ini
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3
uses: github/codeql-action/init@6bb031afdd8eb862ea3fc1848194185e076637e5 # v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -62,7 +62,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3
uses: github/codeql-action/autobuild@6bb031afdd8eb862ea3fc1848194185e076637e5 # v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
@@ -76,4 +76,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3
uses: github/codeql-action/analyze@6bb031afdd8eb862ea3fc1848194185e076637e5 # v3
8 changes: 4 additions & 4 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -125,7 +125,7 @@ jobs:
mv .metacov .metacov.$MATRIX_ID
- name: "Upload coverage data"
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
with:
name: metacov-${{ env.MATRIX_ID }}
path: .metacov.*
@@ -170,7 +170,7 @@ jobs:
python igor.py zip_mods
- name: "Download coverage data"
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
with:
pattern: metacov-*
merge-multiple: true
@@ -184,7 +184,7 @@ jobs:
python igor.py combine_html
- name: "Upload HTML report"
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
with:
name: html_report
path: htmlcov
@@ -239,7 +239,7 @@ jobs:
- name: "Download coverage HTML report"
if: ${{ github.ref == 'refs/heads/master' }}
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
with:
name: html_report
path: reports_repo/${{ env.report_dir }}
12 changes: 6 additions & 6 deletions .github/workflows/kit.yml
Original file line number Diff line number Diff line change
@@ -182,7 +182,7 @@ jobs:
python -m twine check wheelhouse/*
- name: "Upload binary wheels"
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
with:
name: dist-${{ env.MATRIX_ID }}
path: wheelhouse/*.whl
@@ -223,7 +223,7 @@ jobs:
python -m twine check dist/*
- name: "Upload non-binary artifacts"
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
with:
name: dist-non-binary
path: dist/*
@@ -255,7 +255,7 @@ jobs:
run: |
# One wheel works for all PyPy versions. PYVERSIONS
# yes, this is weird syntax: https://github.com/pypa/build/issues/202
echo -e "[bdist_wheel]\npython_tag=pp39.pp310" > $DIST_EXTRA_CONFIG
echo -e "[bdist_wheel]\npython_tag=pp39.pp310.pp311" > $DIST_EXTRA_CONFIG
pypy3 -m build -w
- name: "List wheels"
@@ -267,7 +267,7 @@ jobs:
python -m twine check dist/*
- name: "Upload wheels"
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
with:
name: dist-pypy
path: dist/*.whl
@@ -286,7 +286,7 @@ jobs:
id-token: write
steps:
- name: "Download artifacts"
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
with:
pattern: dist-*
merge-multiple: true
@@ -308,7 +308,7 @@ jobs:
ls -alR
- name: "Upload signatures"
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
with:
name: signatures
path: "*.sigstore.json"
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ jobs:

steps:
- name: "Download dists"
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
with:
repository: "nedbat/coveragepy"
run-id: ${{ needs.find-run.outputs.run-id }}
@@ -81,7 +81,7 @@ jobs:
files=$(ls dist 2>/dev/null | wc -l) && [ "$files" -eq $EXPECTED ] || exit 1
- name: "Generate attestations"
uses: actions/attest-build-provenance@520d128f165991a6c774bcb264f323e3d70747f4 # v2.2.0
uses: actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # v2.2.3
with:
subject-path: "dist/*"

@@ -104,7 +104,7 @@ jobs:

steps:
- name: "Download dists"
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
with:
repository: "nedbat/coveragepy"
run-id: ${{ needs.find-run.outputs.run-id }}
@@ -121,7 +121,7 @@ jobs:
files=$(ls dist 2>/dev/null | wc -l) && [ "$files" -eq $EXPECTED ] || exit 1
- name: "Generate attestations"
uses: actions/attest-build-provenance@520d128f165991a6c774bcb264f323e3d70747f4 # v2.2.0
uses: actions/attest-build-provenance@c074443f1aee8d4aeeae555aebba3282517141b2 # v2.2.3
with:
subject-path: "dist/*"

17 changes: 8 additions & 9 deletions .github/workflows/testsuite.yml
Original file line number Diff line number Diff line change
@@ -54,15 +54,14 @@ jobs:
- "3.14"
- "pypy-3.9"
- "pypy-3.10"
exclude:
# Windows pypy 3.9 and 3.10 get stuck with PyPy 7.3.15. I hope to
# unstick them, but I don't want that to block all other progress, so
# skip them for now. These excludes can be removed once GitHub uses
# PyPy 7.3.16 on Windows. https://github.com/pypy/pypy/issues/4876
- os: windows
python-version: "pypy-3.9"
- os: windows
python-version: "pypy-3.10"
- "pypy-3.11"
#
# If we need to exclude any combinations, do it like this:
# exclude:
# # Windows pypy 3.9 and 3.10 get stuck with PyPy 7.3.15.
# - os: windows
# python-version: "pypy-3.10"
#
# If we need to tweak the os version we can do it with an include like
# this:
# include:
30 changes: 29 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -22,6 +22,34 @@ upgrading your version of coverage.py.
.. start-releases
.. _changes_7-7-0:

Version 7.7.0 — 2025-03-16
--------------------------

- The Coverage object has a new method, :meth:`.Coverage.branch_stats` for
getting simple branch information for a module. Closes `issue 1888`_.

- The :class:`Coverage constructor<.Coverage>` now has a ``plugins`` parameter
for passing in plugin objects directly, thanks to `Alex Gaynor <pull
1919_>`_.

- Many constant tests in if statements are now recognized as being optimized
away. For example, previously ``if 13:`` would have been considered a branch
with one path not taken. Now it is understood as always true and no coverage
is missing.

- The experimental sys.monitoring support now works for branch coverage if you
are using Python 3.14.0 alpha 6 or newer. This should reduce the overhead
coverage.py imposes on your test suite. Set the environment variable
``COVERAGE_CORE=sysmon`` to try it out.

- Confirmed support for PyPy 3.11. Thanks Michał Górny.

.. _issue 1888: https://github.com/nedbat/coveragepy/issues/1888
.. _pull 1919: https://github.com/nedbat/coveragepy/pull/1919


.. _changes_7-6-12:

Version 7.6.12 — 2025-02-11
@@ -1695,7 +1723,7 @@ Version 5.4 — 2021-01-24
- Combining files on Windows across drives now works properly, fixing `issue
577`_. Thanks, `Valentin Lab <pr1080_>`_.

- Fix an obscure warning from deep in the _decimal module, as reported in
- Fix an obscure warning from deep in the decimal module, as reported in
`issue 1084`_.

- Update to support Python 3.10 alphas in progress, including `PEP 626: Precise
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -288,6 +288,7 @@ RELNOTES_JSON = tmp/relnotes.json

$(CHANGES_MD): CHANGES.rst $(DOCBIN)
$(SPHINXBUILD) -b rst doc tmp/rst_rst
pandoc --version
pandoc -frst -tmarkdown_strict --markdown-headings=atx --wrap=none tmp/rst_rst/changes.rst > $(CHANGES_MD)

relnotes_json: $(RELNOTES_JSON) ## Convert changelog to JSON for further parsing.
5 changes: 3 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
@@ -25,8 +25,8 @@ Coverage.py runs on these versions of Python:

.. PYVERSIONS
* Python 3.9 through 3.14 alpha 4, including free-threading.
* PyPy3 versions 3.9 and 3.10.
* Python 3.9 through 3.14 alpha 6, including free-threading.
* PyPy3 versions 3.9, 3.10, and 3.11.

Documentation is on `Read the Docs`_. Code repository and issue tracker are on
`GitHub`_.
@@ -35,6 +35,7 @@ Documentation is on `Read the Docs`_. Code repository and issue tracker are on
.. _GitHub: https://github.com/nedbat/coveragepy

**New in 7.x:**
``Coverage.branch_stats()``;
multi-line exclusion patterns;
function/class reporting;
experimental support for sys.monitoring;
9 changes: 9 additions & 0 deletions benchmark/README.rst
Original file line number Diff line number Diff line change
@@ -50,6 +50,15 @@ for the table. There will be a row for each combination of the two dimensions.
The `column` argument is the remaining dimension that is used to add columns to
the table, one for each item in that dimension.

To run a benchmark, create a Python file with a run_experiment call in it.
Many are in run.py, guarded by ``if 0:`` and ``if 1:`` clauses. In the
benchmark directory, run your Python file. If you haven't provided the
``num_runs`` argument to run_experiment, put the number of runs on the command
line::

% cd benchmark
% python3 run.py 3

For example::

run_experiment(
45 changes: 42 additions & 3 deletions benchmark/benchmark.py
Original file line number Diff line number Diff line change
@@ -191,11 +191,15 @@ class ProjectToTest:

# Where can we clone the project from?
git_url: str = ""
local_git: str = ""
slug: str = ""
env_vars: Env_VarsType = {}

def __init__(self) -> None:
url_must_exist(self.git_url)
if self.git_url:
url_must_exist(self.git_url)
if self.local_git:
file_must_exist(self.local_git)
if not self.slug:
if self.git_url:
self.slug = self.git_url.split("/")[-1]
@@ -211,12 +215,13 @@ def make_dir(self) -> None:

def get_source(self, shell: ShellSession, retries: int = 5) -> None:
"""Get the source of the project."""
git_source = self.local_git or self.git_url
for retry in range(retries):
try:
shell.run_command(f"git clone {self.git_url} {self.dir}")
shell.run_command(f"git clone {git_source} {self.dir}")
return
except Exception as e:
print(f"Retrying to clone {self.git_url} due to error:\n{e}")
print(f"Retrying to clone {git_source} due to error:\n{e}")
if retry == retries - 1:
raise e

@@ -423,6 +428,38 @@ def __init__(self, more_pytest_args: str = ""):
self.slug = "mashbranch"


class ProjectPillow(ProjectToTest):
git_url = "https://github.com/python-pillow/Pillow"
local_git = "/src/Pillow"

def __init__(self, more_pytest_args: str = ""):
super().__init__()
self.more_pytest_args = more_pytest_args

def prep_environment(self, env: Env) -> None:
env.shell.run_command(f"{env.python} -m pip install '.[tests]'")

def run_no_coverage(self, env: Env) -> float:
env.shell.run_command(f"{env.python} -m pytest {self.more_pytest_args}")
return env.shell.last_duration

def run_with_coverage(self, env: Env, cov_ver: Coverage) -> float:
env.shell.run_command(f"{env.python} -m pip install {cov_ver.pip_args}")
env.shell.run_command(
f"{env.python} -m pytest --cov=PIL --cov=Tests {self.more_pytest_args}"
)
duration = env.shell.last_duration
report = env.shell.run_command(f"{env.python} -m coverage report --precision=6")
print("Results:", report.splitlines()[-1])
return duration


class ProjectPillowBranch(ProjectPillow):
def __init__(self, more_pytest_args: str = ""):
super().__init__(more_pytest_args="--cov-branch " + more_pytest_args)
self.slug = "Pilbranch"


class ProjectOperator(ProjectToTest):
git_url = "https://github.com/nedbat/operator"

@@ -823,7 +860,9 @@ def __init__(
tweaks: TweaksType = None,
env_vars: Env_VarsType = None,
):
# Check that it really is a coverage source directory.
directory = file_must_exist(directory_name, "coverage directory")
file_must_exist(str(directory / "igor.py"))
super().__init__(
slug=slug,
pip_args=str(directory),
15 changes: 9 additions & 6 deletions benchmark/run.py
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@
],
)

if 1:
if 0:
# Compare N Python versions
vers = [10, 11, 12, 13]
run_experiment(
@@ -93,28 +93,31 @@
],
)

if 0:
if 1:
# Compare sysmon on many projects

run_experiment(
py_versions=[
Python(3, 12),
# Python(3, 12),
AdHocPython("/usr/local/cpython", "main"),
],
cov_versions=[
NoCoverage("nocov"),
CoverageSource(slug="ctrace", env_vars={"COVERAGE_CORE": "ctrace"}),
CoverageSource(slug="sysmon", env_vars={"COVERAGE_CORE": "sysmon"}),
],
projects=[
ProjectPillow(), #"-k test_pickle"),
ProjectPillowBranch(), #"-k test_pickle"),
# ProjectSphinx(), # Works, slow
ProjectPygments(), # Works
# ProjectPygments(), # Doesn't work on 3.14
# ProjectRich(), # Doesn't work
# ProjectTornado(), # Works, tests fail
# ProjectDulwich(), # Works
# ProjectBlack(), # Works, slow
# ProjectMpmath(), # Works, slow
ProjectMypy(), # Works, slow
# ProjectHtml5lib(), # Works
# ProjectMypy(), # Works, slow
# ProjectHtml5lib(), # Doesn't work on 3.14
# ProjectUrllib3(), # Works
],
rows=["pyver", "proj"],
2 changes: 1 addition & 1 deletion coverage/cmdline.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
from __future__ import annotations

import glob
import optparse # pylint: disable=deprecated-module
import optparse
import os
import os.path
import shlex
Loading