From f07a4394e2a39630cc4fe67c23cb1ea1ec95313f Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 6 Apr 2023 10:39:56 -0400 Subject: [PATCH 01/30] build: can't clean a thing until it exists!? --- Makefile | 1 + howto.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/Makefile b/Makefile index f82f2ee27..847e50987 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,7 @@ clean_platform: clean: clean_platform ## Remove artifacts of test execution, installation, etc. @echo "Cleaning..." @-pip uninstall -yq coverage + @mkdir -p build # so the chmod won't fail if build doesn't exist @chmod -R 777 build @rm -rf build coverage.egg-info dist htmlcov @rm -f *.bak */*.bak */*/*.bak */*/*/*.bak */*/*/*/*.bak */*/*/*/*/*.bak diff --git a/howto.txt b/howto.txt index 24f01ecb6..e74aa77d9 100644 --- a/howto.txt +++ b/howto.txt @@ -83,6 +83,7 @@ - wait for the new tag build to finish successfully. - @ https://readthedocs.org/dashboard/coverage/advanced/ - change the default version to the new version +- Don't forget to merge the bump-version branch - things to automate: - url to link to latest changes in docs - next version.py line From 27087ff2287c2b5a8db4db93484e533f290af1bc Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 6 Apr 2023 10:40:10 -0400 Subject: [PATCH 02/30] build: bump version --- CHANGES.rst | 6 ++++++ coverage/version.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 937835ccc..f1555179f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -17,6 +17,12 @@ development at the same time, such as 4.5.x and 5.0. .. Version 9.8.1 — 2027-07-27 .. -------------------------- +Unreleased +---------- + +Nothing yet. + + .. scriv-start-here .. _changes_7-2-3: diff --git a/coverage/version.py b/coverage/version.py index 9cf7d9d19..d9f10f4cf 100644 --- a/coverage/version.py +++ b/coverage/version.py @@ -8,8 +8,8 @@ # version_info: same semantics as sys.version_info. # _dev: the .devN suffix if any. -version_info = (7, 2, 3, "final", 0) -_dev = 0 +version_info = (7, 2, 4, "alpha", 0) +_dev = 1 def _make_version( From dd724f69a4d9d0641389bb8d830475fa1091e094 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 12 Apr 2023 07:41:47 -0400 Subject: [PATCH 03/30] build: find other .so files to clean between runs The build/lib.macosx-13.3-x86_64-cpython-312/coverage/tracer.cpython-312-darwin.so file seems to cause VirtualenvTests to fail if it's carried over from 3.12.0a7 to 3.12.0a7+ built from source. Clean it out to prevent false failures. --- igor.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/igor.py b/igor.py index ad0dbf8c5..a7c5f9635 100644 --- a/igor.py +++ b/igor.py @@ -12,6 +12,7 @@ import datetime import glob import inspect +import itertools import os import platform import pprint @@ -77,10 +78,11 @@ def do_remove_extension(*args): "-c", "import coverage; print(coverage.__file__)" ], encoding="utf-8").strip()) + roots = [root] else: - root = "coverage" + roots = ["coverage", "build/*/coverage"] - for pattern in so_patterns: + for root, pattern in itertools.product(roots, so_patterns): pattern = os.path.join(root, pattern.strip()) if VERBOSITY: print(f"Searching for {pattern}") From 7b68d1286cefb45225ee851a6e9b5d47594d69cb Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 13 Apr 2023 10:04:44 -0400 Subject: [PATCH 04/30] build: use htmlpreview.github.com for simpler report publishing --- .github/workflows/coverage.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 60e8d0a29..ab0c1142a 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -178,7 +178,7 @@ jobs: echo "sha10=$SHA10" >> $GITHUB_ENV echo "slug=$SLUG" >> $GITHUB_ENV echo "report_dir=$REPORT_DIR" >> $GITHUB_ENV - echo "url=https://nedbat.github.io/coverage-reports/$REPORT_DIR" >> $GITHUB_ENV + echo "url=https://htmlpreview.github.io/?https://github.com/nedbat/coverage-reports/blob/main/reports/$SLUG/htmlcov/index.html" >> $GITHUB_ENV echo "branch=${REF#refs/heads/}" >> $GITHUB_ENV - name: "Summarize" @@ -217,6 +217,8 @@ jobs: # Make the commit message. echo "${{ env.total }}% - $COMMIT_MESSAGE" > commit.txt echo "" >> commit.txt + echo "[View the report](${{ env.url }})" >> commit.txt + echo "" >> commit.txt echo "${{ env.url }}" >> commit.txt echo "${{ env.sha10 }}: ${{ env.branch }}" >> commit.txt # Commit. From 45ed6ea029d67265ed3aeeb6b0ec8fc2f1f97b5c Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 14 Apr 2023 15:39:39 -0400 Subject: [PATCH 05/30] chore: make upgrade --- doc/requirements.pip | 6 +++--- requirements/dev.pip | 24 +++++++++++------------- requirements/kit.pip | 6 +++--- requirements/lint.pip | 21 ++++++++++----------- requirements/mypy.pip | 14 ++++++-------- requirements/pip-tools.pip | 6 +++--- requirements/pip.pip | 4 ++-- requirements/pytest.pip | 12 +++++------- requirements/tox.pip | 8 ++++---- 9 files changed, 47 insertions(+), 54 deletions(-) diff --git a/doc/requirements.pip b/doc/requirements.pip index b13fedcd8..f9ce6d1ce 100644 --- a/doc/requirements.pip +++ b/doc/requirements.pip @@ -32,7 +32,7 @@ idna==3.4 # via requests imagesize==1.4.1 # via sphinx -importlib-metadata==6.1.0 +importlib-metadata==6.3.0 # via # click # sphinx @@ -45,13 +45,13 @@ livereload==2.6.3 # via sphinx-autobuild markupsafe==2.1.2 # via jinja2 -packaging==23.0 +packaging==23.1 # via sphinx pyenchant==3.2.2 # via # -r doc/requirements.in # sphinxcontrib-spelling -pygments==2.14.0 +pygments==2.15.0 # via sphinx pytz==2023.3 # via babel diff --git a/requirements/dev.pip b/requirements/dev.pip index 76304efc0..ba9bc39ea 100644 --- a/requirements/dev.pip +++ b/requirements/dev.pip @@ -4,12 +4,10 @@ # # make upgrade # -astroid==2.15.1 +astroid==2.15.2 # via pylint attrs==22.2.0 - # via - # hypothesis - # pytest + # via hypothesis bleach==6.0.0 # via readme-renderer build==0.10.0 @@ -43,7 +41,7 @@ exceptiongroup==1.1.1 # pytest execnet==1.9.0 # via pytest-xdist -filelock==3.10.7 +filelock==3.11.0 # via # tox # virtualenv @@ -51,11 +49,11 @@ flaky==3.7.0 # via -r requirements/pytest.in greenlet==2.0.2 # via -r requirements/dev.in -hypothesis==6.70.2 +hypothesis==6.71.0 # via -r requirements/pytest.in idna==3.4 # via requests -importlib-metadata==6.1.0 +importlib-metadata==6.3.0 # via # build # keyring @@ -88,7 +86,7 @@ mdurl==0.1.2 # via markdown-it-py more-itertools==9.1.0 # via jaraco-classes -packaging==23.0 +packaging==23.1 # via # build # pudb @@ -110,18 +108,18 @@ pluggy==1.0.0 # tox pudb==2022.1.3 # via -r requirements/dev.in -pygments==2.14.0 +pygments==2.15.0 # via # pudb # readme-renderer # rich -pylint==2.17.1 +pylint==2.17.2 # via -r requirements/dev.in pyproject-api==1.5.1 # via tox pyproject-hooks==1.0.0 # via build -pytest==7.2.2 +pytest==7.3.1 # via # -r requirements/pytest.in # pytest-xdist @@ -140,7 +138,7 @@ requests-toolbelt==0.10.1 # via twine rfc3986==2.0.0 # via twine -rich==13.3.3 +rich==13.3.4 # via twine six==1.16.0 # via bleach @@ -157,7 +155,7 @@ tomli==2.0.1 # tox tomlkit==0.11.7 # via pylint -tox==4.4.8 +tox==4.4.12 # via # -r requirements/tox.in # tox-gh diff --git a/requirements/kit.pip b/requirements/kit.pip index a126aa357..a2a6b470e 100644 --- a/requirements/kit.pip +++ b/requirements/kit.pip @@ -18,13 +18,13 @@ cibuildwheel==2.12.1 # via -r requirements/kit.in colorama==0.4.6 # via -r requirements/kit.in -filelock==3.10.7 +filelock==3.11.0 # via cibuildwheel -importlib-metadata==6.1.0 +importlib-metadata==6.3.0 # via # auditwheel # build -packaging==23.0 +packaging==23.1 # via # build # cibuildwheel diff --git a/requirements/lint.pip b/requirements/lint.pip index af91931e1..f5c5c5fc8 100644 --- a/requirements/lint.pip +++ b/requirements/lint.pip @@ -6,12 +6,11 @@ # alabaster==0.7.13 # via sphinx -astroid==2.15.1 +astroid==2.15.2 # via pylint attrs==22.2.0 # via # hypothesis - # pytest # scriv babel==2.12.1 # via sphinx @@ -60,7 +59,7 @@ exceptiongroup==1.1.1 # pytest execnet==1.9.0 # via pytest-xdist -filelock==3.10.7 +filelock==3.11.0 # via # tox # virtualenv @@ -68,13 +67,13 @@ flaky==3.7.0 # via -r requirements/pytest.in greenlet==2.0.2 # via -r requirements/dev.in -hypothesis==6.70.2 +hypothesis==6.71.0 # via -r requirements/pytest.in idna==3.4 # via requests imagesize==1.4.1 # via sphinx -importlib-metadata==6.1.0 +importlib-metadata==6.3.0 # via # build # click @@ -118,7 +117,7 @@ mdurl==0.1.2 # via markdown-it-py more-itertools==9.1.0 # via jaraco-classes -packaging==23.0 +packaging==23.1 # via # build # pudb @@ -145,19 +144,19 @@ pyenchant==3.2.2 # via # -r doc/requirements.in # sphinxcontrib-spelling -pygments==2.14.0 +pygments==2.15.0 # via # pudb # readme-renderer # rich # sphinx -pylint==2.17.1 +pylint==2.17.2 # via -r requirements/dev.in pyproject-api==1.5.1 # via tox pyproject-hooks==1.0.0 # via build -pytest==7.2.2 +pytest==7.3.1 # via # -r requirements/pytest.in # pytest-xdist @@ -180,7 +179,7 @@ requests-toolbelt==0.10.1 # via twine rfc3986==2.0.0 # via twine -rich==13.3.3 +rich==13.3.4 # via twine scriv==1.2.1 # via -r doc/requirements.in @@ -235,7 +234,7 @@ tomlkit==0.11.7 # via pylint tornado==6.2 # via livereload -tox==4.4.8 +tox==4.4.12 # via # -r requirements/tox.in # tox-gh diff --git a/requirements/mypy.pip b/requirements/mypy.pip index ae1bbd97b..1ce28abfb 100644 --- a/requirements/mypy.pip +++ b/requirements/mypy.pip @@ -5,9 +5,7 @@ # make upgrade # attrs==22.2.0 - # via - # hypothesis - # pytest + # via hypothesis colorama==0.4.6 # via -r requirements/pytest.in exceptiongroup==1.1.1 @@ -18,23 +16,23 @@ execnet==1.9.0 # via pytest-xdist flaky==3.7.0 # via -r requirements/pytest.in -hypothesis==6.70.2 +hypothesis==6.71.0 # via -r requirements/pytest.in -importlib-metadata==6.1.0 +importlib-metadata==6.3.0 # via # pluggy # pytest iniconfig==2.0.0 # via pytest -mypy==1.1.1 +mypy==1.2.0 # via -r requirements/mypy.in mypy-extensions==1.0.0 # via mypy -packaging==23.0 +packaging==23.1 # via pytest pluggy==1.0.0 # via pytest -pytest==7.2.2 +pytest==7.3.1 # via # -r requirements/pytest.in # pytest-xdist diff --git a/requirements/pip-tools.pip b/requirements/pip-tools.pip index 000f707a7..1b62e578b 100644 --- a/requirements/pip-tools.pip +++ b/requirements/pip-tools.pip @@ -8,13 +8,13 @@ build==0.10.0 # via pip-tools click==8.1.3 # via pip-tools -importlib-metadata==6.1.0 +importlib-metadata==6.3.0 # via # build # click -packaging==23.0 +packaging==23.1 # via build -pip-tools==6.12.3 +pip-tools==6.13.0 # via -r requirements/pip-tools.in pyproject-hooks==1.0.0 # via build diff --git a/requirements/pip.pip b/requirements/pip.pip index 927943a5e..49445c0b1 100644 --- a/requirements/pip.pip +++ b/requirements/pip.pip @@ -6,9 +6,9 @@ # distlib==0.3.6 # via virtualenv -filelock==3.10.7 +filelock==3.11.0 # via virtualenv -importlib-metadata==6.1.0 +importlib-metadata==6.3.0 # via virtualenv platformdirs==3.2.0 # via virtualenv diff --git a/requirements/pytest.pip b/requirements/pytest.pip index 478860a97..65e046b48 100644 --- a/requirements/pytest.pip +++ b/requirements/pytest.pip @@ -5,9 +5,7 @@ # make upgrade # attrs==22.2.0 - # via - # hypothesis - # pytest + # via hypothesis colorama==0.4.6 # via -r requirements/pytest.in exceptiongroup==1.1.1 @@ -18,19 +16,19 @@ execnet==1.9.0 # via pytest-xdist flaky==3.7.0 # via -r requirements/pytest.in -hypothesis==6.70.2 +hypothesis==6.71.0 # via -r requirements/pytest.in -importlib-metadata==6.1.0 +importlib-metadata==6.3.0 # via # pluggy # pytest iniconfig==2.0.0 # via pytest -packaging==23.0 +packaging==23.1 # via pytest pluggy==1.0.0 # via pytest -pytest==7.2.2 +pytest==7.3.1 # via # -r requirements/pytest.in # pytest-xdist diff --git a/requirements/tox.pip b/requirements/tox.pip index c02835cbb..288dc54eb 100644 --- a/requirements/tox.pip +++ b/requirements/tox.pip @@ -14,16 +14,16 @@ colorama==0.4.6 # tox distlib==0.3.6 # via virtualenv -filelock==3.10.7 +filelock==3.11.0 # via # tox # virtualenv -importlib-metadata==6.1.0 +importlib-metadata==6.3.0 # via # pluggy # tox # virtualenv -packaging==23.0 +packaging==23.1 # via # pyproject-api # tox @@ -39,7 +39,7 @@ tomli==2.0.1 # via # pyproject-api # tox -tox==4.4.8 +tox==4.4.12 # via # -r requirements/tox.in # tox-gh From 3a476c3dac1da91888f08ffa527a6da95f6b07dc Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 19 Apr 2023 11:22:26 -0400 Subject: [PATCH 06/30] fix: Python 3.12 removed pkgutils --- tests/test_venv.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/test_venv.py b/tests/test_venv.py index ae5b303f7..a23561921 100644 --- a/tests/test_venv.py +++ b/tests/test_venv.py @@ -116,8 +116,12 @@ def sixth(x): __path__ = extend_path(__path__, __name__) """) make_file("bug888/app/testcov/main.py", """\ - import pkg_resources - for entry_point in pkg_resources.iter_entry_points('plugins'): + try: # pragma: no cover + entry_points = __import__("pkg_resources").iter_entry_points('plugins') + except ImportError: # pragma: no cover + import importlib.metadata + entry_points = importlib.metadata.entry_points(group="plugins") + for entry_point in entry_points: entry_point.load()() """) make_file("bug888/plugin/setup.py", """\ From c0a17c5d48de0f17a0c6789327b9ff910ab42d55 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 24 Apr 2023 12:16:46 -0600 Subject: [PATCH 07/30] chore: make upgrade --- doc/requirements.pip | 9 +++++---- requirements/dev.pip | 19 ++++++++++--------- requirements/kit.pip | 6 +++--- requirements/lint.pip | 21 +++++++++++---------- requirements/mypy.pip | 7 ++++--- requirements/pip-tools.pip | 4 ++-- requirements/pip.pip | 8 ++++---- requirements/pytest.pip | 7 ++++--- requirements/tox.pip | 8 ++++---- 9 files changed, 47 insertions(+), 42 deletions(-) diff --git a/doc/requirements.pip b/doc/requirements.pip index f9ce6d1ce..5bd841b0e 100644 --- a/doc/requirements.pip +++ b/doc/requirements.pip @@ -6,7 +6,7 @@ # alabaster==0.7.13 # via sphinx -attrs==22.2.0 +attrs==23.1.0 # via scriv babel==2.12.1 # via sphinx @@ -32,8 +32,9 @@ idna==3.4 # via requests imagesize==1.4.1 # via sphinx -importlib-metadata==6.3.0 +importlib-metadata==6.6.0 # via + # attrs # click # sphinx # sphinxcontrib-spelling @@ -51,7 +52,7 @@ pyenchant==3.2.2 # via # -r doc/requirements.in # sphinxcontrib-spelling -pygments==2.15.0 +pygments==2.15.1 # via sphinx pytz==2023.3 # via babel @@ -59,7 +60,7 @@ requests==2.28.2 # via # scriv # sphinx -scriv==1.2.1 +scriv==1.3.1 # via -r doc/requirements.in six==1.16.0 # via livereload diff --git a/requirements/dev.pip b/requirements/dev.pip index ba9bc39ea..60d65c9ac 100644 --- a/requirements/dev.pip +++ b/requirements/dev.pip @@ -4,9 +4,9 @@ # # make upgrade # -astroid==2.15.2 +astroid==2.15.4 # via pylint -attrs==22.2.0 +attrs==23.1.0 # via hypothesis bleach==6.0.0 # via readme-renderer @@ -41,7 +41,7 @@ exceptiongroup==1.1.1 # pytest execnet==1.9.0 # via pytest-xdist -filelock==3.11.0 +filelock==3.12.0 # via # tox # virtualenv @@ -49,12 +49,13 @@ flaky==3.7.0 # via -r requirements/pytest.in greenlet==2.0.2 # via -r requirements/dev.in -hypothesis==6.71.0 +hypothesis==6.72.2 # via -r requirements/pytest.in idna==3.4 # via requests -importlib-metadata==6.3.0 +importlib-metadata==6.6.0 # via + # attrs # build # keyring # pluggy @@ -108,7 +109,7 @@ pluggy==1.0.0 # tox pudb==2022.1.3 # via -r requirements/dev.in -pygments==2.15.0 +pygments==2.15.1 # via # pudb # readme-renderer @@ -155,7 +156,7 @@ tomli==2.0.1 # tox tomlkit==0.11.7 # via pylint -tox==4.4.12 +tox==4.5.0 # via # -r requirements/tox.in # tox-gh @@ -184,7 +185,7 @@ urwid==2.1.2 # urwid-readline urwid-readline==0.13 # via pudb -virtualenv==20.21.0 +virtualenv==20.22.0 # via # -r requirements/pip.in # tox @@ -198,7 +199,7 @@ zipp==3.15.0 # importlib-resources # The following packages are considered to be unsafe in a requirements file: -pip==23.0.1 +pip==23.1.1 # via -r requirements/pip.in setuptools==65.7.0 # via diff --git a/requirements/kit.pip b/requirements/kit.pip index a2a6b470e..27360a022 100644 --- a/requirements/kit.pip +++ b/requirements/kit.pip @@ -14,13 +14,13 @@ build==0.10.0 # via -r requirements/kit.in certifi==2022.12.7 # via cibuildwheel -cibuildwheel==2.12.1 +cibuildwheel==2.12.3 # via -r requirements/kit.in colorama==0.4.6 # via -r requirements/kit.in -filelock==3.11.0 +filelock==3.12.0 # via cibuildwheel -importlib-metadata==6.3.0 +importlib-metadata==6.6.0 # via # auditwheel # build diff --git a/requirements/lint.pip b/requirements/lint.pip index f5c5c5fc8..504c34bcc 100644 --- a/requirements/lint.pip +++ b/requirements/lint.pip @@ -6,9 +6,9 @@ # alabaster==0.7.13 # via sphinx -astroid==2.15.2 +astroid==2.15.4 # via pylint -attrs==22.2.0 +attrs==23.1.0 # via # hypothesis # scriv @@ -59,7 +59,7 @@ exceptiongroup==1.1.1 # pytest execnet==1.9.0 # via pytest-xdist -filelock==3.11.0 +filelock==3.12.0 # via # tox # virtualenv @@ -67,14 +67,15 @@ flaky==3.7.0 # via -r requirements/pytest.in greenlet==2.0.2 # via -r requirements/dev.in -hypothesis==6.71.0 +hypothesis==6.72.2 # via -r requirements/pytest.in idna==3.4 # via requests imagesize==1.4.1 # via sphinx -importlib-metadata==6.3.0 +importlib-metadata==6.6.0 # via + # attrs # build # click # keyring @@ -144,7 +145,7 @@ pyenchant==3.2.2 # via # -r doc/requirements.in # sphinxcontrib-spelling -pygments==2.15.0 +pygments==2.15.1 # via # pudb # readme-renderer @@ -181,7 +182,7 @@ rfc3986==2.0.0 # via twine rich==13.3.4 # via twine -scriv==1.2.1 +scriv==1.3.1 # via -r doc/requirements.in six==1.16.0 # via @@ -234,7 +235,7 @@ tomlkit==0.11.7 # via pylint tornado==6.2 # via livereload -tox==4.4.12 +tox==4.5.0 # via # -r requirements/tox.in # tox-gh @@ -263,7 +264,7 @@ urwid==2.1.2 # urwid-readline urwid-readline==0.13 # via pudb -virtualenv==20.21.0 +virtualenv==20.22.0 # via # -r requirements/pip.in # tox @@ -277,7 +278,7 @@ zipp==3.15.0 # importlib-resources # The following packages are considered to be unsafe in a requirements file: -pip==23.0.1 +pip==23.1.1 # via -r requirements/pip.in setuptools==65.7.0 # via diff --git a/requirements/mypy.pip b/requirements/mypy.pip index 1ce28abfb..4e1ef4835 100644 --- a/requirements/mypy.pip +++ b/requirements/mypy.pip @@ -4,7 +4,7 @@ # # make upgrade # -attrs==22.2.0 +attrs==23.1.0 # via hypothesis colorama==0.4.6 # via -r requirements/pytest.in @@ -16,10 +16,11 @@ execnet==1.9.0 # via pytest-xdist flaky==3.7.0 # via -r requirements/pytest.in -hypothesis==6.71.0 +hypothesis==6.72.2 # via -r requirements/pytest.in -importlib-metadata==6.3.0 +importlib-metadata==6.6.0 # via + # attrs # pluggy # pytest iniconfig==2.0.0 diff --git a/requirements/pip-tools.pip b/requirements/pip-tools.pip index 1b62e578b..e26ce5e59 100644 --- a/requirements/pip-tools.pip +++ b/requirements/pip-tools.pip @@ -8,7 +8,7 @@ build==0.10.0 # via pip-tools click==8.1.3 # via pip-tools -importlib-metadata==6.3.0 +importlib-metadata==6.6.0 # via # build # click @@ -30,7 +30,7 @@ zipp==3.15.0 # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: -pip==23.0.1 +pip==23.1.1 # via pip-tools setuptools==65.7.0 # via diff --git a/requirements/pip.pip b/requirements/pip.pip index 49445c0b1..8ba199868 100644 --- a/requirements/pip.pip +++ b/requirements/pip.pip @@ -6,9 +6,9 @@ # distlib==0.3.6 # via virtualenv -filelock==3.11.0 +filelock==3.12.0 # via virtualenv -importlib-metadata==6.3.0 +importlib-metadata==6.6.0 # via virtualenv platformdirs==3.2.0 # via virtualenv @@ -16,13 +16,13 @@ typing-extensions==4.5.0 # via # importlib-metadata # platformdirs -virtualenv==20.21.0 +virtualenv==20.22.0 # via -r requirements/pip.in zipp==3.15.0 # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: -pip==23.0.1 +pip==23.1.1 # via -r requirements/pip.in setuptools==65.7.0 # via -r requirements/pip.in diff --git a/requirements/pytest.pip b/requirements/pytest.pip index 65e046b48..d825d8e68 100644 --- a/requirements/pytest.pip +++ b/requirements/pytest.pip @@ -4,7 +4,7 @@ # # make upgrade # -attrs==22.2.0 +attrs==23.1.0 # via hypothesis colorama==0.4.6 # via -r requirements/pytest.in @@ -16,10 +16,11 @@ execnet==1.9.0 # via pytest-xdist flaky==3.7.0 # via -r requirements/pytest.in -hypothesis==6.71.0 +hypothesis==6.72.2 # via -r requirements/pytest.in -importlib-metadata==6.3.0 +importlib-metadata==6.6.0 # via + # attrs # pluggy # pytest iniconfig==2.0.0 diff --git a/requirements/tox.pip b/requirements/tox.pip index 288dc54eb..5d4389680 100644 --- a/requirements/tox.pip +++ b/requirements/tox.pip @@ -14,11 +14,11 @@ colorama==0.4.6 # tox distlib==0.3.6 # via virtualenv -filelock==3.11.0 +filelock==3.12.0 # via # tox # virtualenv -importlib-metadata==6.3.0 +importlib-metadata==6.6.0 # via # pluggy # tox @@ -39,7 +39,7 @@ tomli==2.0.1 # via # pyproject-api # tox -tox==4.4.12 +tox==4.5.0 # via # -r requirements/tox.in # tox-gh @@ -50,7 +50,7 @@ typing-extensions==4.5.0 # importlib-metadata # platformdirs # tox -virtualenv==20.21.0 +virtualenv==20.22.0 # via tox zipp==3.15.0 # via importlib-metadata From f41f8382f9035f8842f433a568b889f10d34ea60 Mon Sep 17 00:00:00 2001 From: Marc Gibbons <1726961+marcgibbons@users.noreply.github.com> Date: Mon, 24 Apr 2023 12:44:49 -0600 Subject: [PATCH 08/30] Set lint `basepython` to 3.7 3.7 is the lowest common denominator of supported versions. Linting on more recent versions introduces new error messages. --- tox.ini | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tox.ini b/tox.ini index 0a1fa6f60..51c39bd1e 100644 --- a/tox.ini +++ b/tox.ini @@ -70,6 +70,8 @@ commands = - sphinx-build -b html -b linkcheck -aEnQW doc doc/_build/html [testenv:lint] +# PYVERSIONS +basepython = python3.7 deps = -r requirements/lint.pip From 84e43c402fb429c7aa0432dc46229158fb5e1889 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 25 Apr 2023 06:14:52 -0600 Subject: [PATCH 09/30] build: remove some unneeded tox steps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bernát Gábor pointed out that we don't need the pip installation steps because tox will have already installed the project. --- tox.ini | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tox.ini b/tox.ini index 51c39bd1e..ebc998162 100644 --- a/tox.ini +++ b/tox.ini @@ -9,9 +9,9 @@ skip_missing_interpreters = {env:COVERAGE_SKIP_MISSING_INTERPRETERS:True} toxworkdir = {env:TOXWORKDIR:.tox} [testenv] -usedevelop = True extras = toml +package = editable # PYVERSIONS deps = @@ -30,15 +30,11 @@ setenv = # so override any local setting. PYTHONPYCACHEPREFIX= -# $set_env.py: COVERAGE_PIP_ARGS - Extra arguments for `pip install` -# `--no-build-isolation` will let tox work with no network. commands = # Create tests/zipmods.zip python igor.py zip_mods - # Build the C extension and test with the CTracer - python setup.py --quiet build_ext --inplace - python -m pip install {env:COVERAGE_PIP_ARGS} -q -e . + # Test with the CTracer that normal installation gives us. python igor.py test_with_tracer c {posargs} # Remove the C extension so that we can test the PyTracer From c6610b30e8f01f6107e0fce07eca35c04b1c09ce Mon Sep 17 00:00:00 2001 From: Brian Grohe Date: Mon, 24 Apr 2023 17:46:37 +0000 Subject: [PATCH 10/30] docs: a new page about migrating between versions Added basic migraton docs changes Remove change that likely will not require migration changes Cannot determine what the behavior was before Updated ** replacement suggestion Remove extra indent at end of file Fix linting issue that needed a trailing indent Fix a typo in docs Removed .gitignore corrected a single rule Added basic migraton docs changes Fix linting issue that needed a trailing indent Fix a typo in docs Correct grammar issue Co-authored-by: Ned Batchelder Correct rule and spelling Remove personal gitignore config Removed duplicated license text Added extra space Take suggestions from ned Co-authored-by: Ned Batchelder --- doc/index.rst | 1 + doc/migrations.rst | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 doc/migrations.rst diff --git a/doc/index.rst b/doc/index.rst index b11dc90e9..30ddf88b4 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -234,4 +234,5 @@ More information trouble faq Change history + Migrating version notes sleepy diff --git a/doc/migrations.rst b/doc/migrations.rst new file mode 100644 index 000000000..e618cdc00 --- /dev/null +++ b/doc/migrations.rst @@ -0,0 +1,26 @@ +.. Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 +.. For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt + +.. _migrations: + +========================== +Migrating between versions +========================== + +.. _migrating_6x_7x: + +Migrating 6.5.x — 7.0.x +----------------------- + +- The way that wildcards when specifying file paths work in certain cases has changed in 7.0.x: + + - Previously, ``*`` would incorrectly match directory separators, making + precise matching difficult. Patterns such as ``*tests/*`` + will need to be changed to ``*/tests/*``. + + - ``**`` now matches any number of nested directories. If you wish to retain the behavior of + ``**/tests/*`` in previous versions then ``*/**/tests/*`` can be used instead. + +- When remapping file paths with ``[paths]``, a path will be remapped only if + the resulting path exists. Ensure that remapped ``[paths]`` exist when upgrading + as this is now being enforced. From d6e621aa3f492ffb4f630a914cc79a392afb95a2 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 25 Apr 2023 08:51:02 -0600 Subject: [PATCH 11/30] docs: clean up for #1610. Thanks, Brian Grohe. --- CHANGES.rst | 5 ++++- CONTRIBUTORS.txt | 1 + doc/index.rst | 2 +- doc/{migrations.rst => migrating.rst} | 11 +++++++---- 4 files changed, 13 insertions(+), 6 deletions(-) rename doc/{migrations.rst => migrating.rst} (78%) diff --git a/CHANGES.rst b/CHANGES.rst index f1555179f..ec31b21b6 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -20,8 +20,11 @@ development at the same time, such as 4.5.x and 5.0. Unreleased ---------- -Nothing yet. +- Docs: a new :ref:`Migrating page ` with details about how to + migrate between major versions of coverage.py. It currently covers the + wildcard changes in 7.x. Thanks, `Brian Grohe `_. +.. _pull 1610: https://github.com/nedbat/coveragepy/pull/1610 .. scriv-start-here diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 0ba35f628..4d387ef08 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -32,6 +32,7 @@ Bill Hart Bradley Burns Brandon Rhodes Brett Cannon +Brian Grohe Bruno P. Kinoshita Buck Evan Calen Pennington diff --git a/doc/index.rst b/doc/index.rst index 30ddf88b4..2420aa6f8 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -234,5 +234,5 @@ More information trouble faq Change history - Migrating version notes + migrating sleepy diff --git a/doc/migrations.rst b/doc/migrating.rst similarity index 78% rename from doc/migrations.rst rename to doc/migrating.rst index e618cdc00..7a5e65df8 100644 --- a/doc/migrations.rst +++ b/doc/migrating.rst @@ -1,18 +1,21 @@ .. Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 .. For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt -.. _migrations: +.. _migrating: ========================== Migrating between versions ========================== +New major versions of coverage.py might require you to adjust your settings, +options, or other aspects of your use. This page details those changes. + .. _migrating_6x_7x: -Migrating 6.5.x — 7.0.x ------------------------ +Migrating from 6.x to 7.x +------------------------- -- The way that wildcards when specifying file paths work in certain cases has changed in 7.0.x: +- The way that wildcards when specifying file paths work in certain cases has changed in 7.x: - Previously, ``*`` would incorrectly match directory separators, making precise matching difficult. Patterns such as ``*tests/*`` From 74f179b591e57fe042bd510b07edcdedcacac624 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 26 Apr 2023 10:35:26 -0400 Subject: [PATCH 12/30] docs: thanks Marc Gibbons for the tox.ini fix in f41f8382 How can it be that we now have three Marcs, but only just got our first Brian?!? --- CONTRIBUTORS.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 4d387ef08..f5f2898fd 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -112,6 +112,7 @@ Loïc Dachary Lorenzo Micò Manuel Jacob Marc Abramowitz +Marc Gibbons Marc Legendre Marcelo Trylesinski Marcus Cobden From 5f31ff9ae35cee27a25f4413664c0ac527fc3a15 Mon Sep 17 00:00:00 2001 From: Ricardo Newbery Date: Wed, 26 Apr 2023 17:31:18 -0600 Subject: [PATCH 13/30] feat: add hyperlink to console output (#1613) * Add hyperlink to console output * python 3.7 compat version of detecting console tty --- coverage/html.py | 10 +++++++++- coverage/report.py | 8 +++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/coverage/html.py b/coverage/html.py index 570760604..4e594343c 100644 --- a/coverage/html.py +++ b/coverage/html.py @@ -13,6 +13,7 @@ import re import shutil import string # pylint: disable=deprecated-module +import sys from dataclasses import dataclass from typing import Any, Dict, Iterable, List, Optional, Tuple, TYPE_CHECKING, cast @@ -493,7 +494,14 @@ def index_file(self, first_html: str, final_html: str) -> None: index_file = os.path.join(self.directory, "index.html") write_html(index_file, html) - self.coverage._message(f"Wrote HTML report to {index_file}") + + if sys.stdout.isatty(): + file_path = f"file://{os.path.abspath(index_file)}" + print_path = f"\033]8;;{file_path}\a{index_file}\033]8;;\a" + else: + print_path = index_file + + self.coverage._message(f"Wrote HTML report to {print_path}") # Write the latest hashes for next time. self.incr.write() diff --git a/coverage/report.py b/coverage/report.py index 09eed0a82..1e14eb78e 100644 --- a/coverage/report.py +++ b/coverage/report.py @@ -5,6 +5,7 @@ from __future__ import annotations +import os import sys from typing import Callable, Iterable, Iterator, IO, Optional, Tuple, TYPE_CHECKING @@ -58,7 +59,12 @@ def render_report( try: ret = reporter.report(morfs, outfile=outfile) if file_to_close is not None: - msgfn(f"Wrote {reporter.report_type} to {output_path}") + if sys.stdout.isatty(): + file_path = f"file://{os.path.abspath(output_path)}" + print_path = f"\033]8;;{file_path}\a{output_path}\033]8;;\a" + else: + print_path = output_path + msgfn(f"Wrote {reporter.report_type} to {print_path}") delete_file = False return ret finally: From 40cc55c0dc18d999cd4d3c1b278d6e120f858ab5 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 26 Apr 2023 18:36:02 -0400 Subject: [PATCH 14/30] fix: no need for terminal url except for html report --- CHANGES.rst | 7 +++++++ CONTRIBUTORS.txt | 1 + coverage/report.py | 8 +------- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index ec31b21b6..5f89576ff 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -20,11 +20,18 @@ development at the same time, such as 4.5.x and 5.0. Unreleased ---------- +- When the HTML report location is printed to the terminal, it's now a + terminal-compatible URL, so that you can click the location to open the HTML + file in your browser. Finishes `issue 1523`_ thanks to `Ricardo Newbery + `_. + - Docs: a new :ref:`Migrating page ` with details about how to migrate between major versions of coverage.py. It currently covers the wildcard changes in 7.x. Thanks, `Brian Grohe `_. +.. _issue 1523: https://github.com/nedbat/coveragepy/issues/1523 .. _pull 1610: https://github.com/nedbat/coveragepy/pull/1610 +.. _pull 1613: https://github.com/nedbat/coveragepy/pull/1613 .. scriv-start-here diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index f5f2898fd..b02f7add9 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -147,6 +147,7 @@ Peter Ebden Peter Portante Phebe Polk Reya B +Ricardo Newbery Rodrigue Cloutier Roger Hu Ross Lawley diff --git a/coverage/report.py b/coverage/report.py index 1e14eb78e..09eed0a82 100644 --- a/coverage/report.py +++ b/coverage/report.py @@ -5,7 +5,6 @@ from __future__ import annotations -import os import sys from typing import Callable, Iterable, Iterator, IO, Optional, Tuple, TYPE_CHECKING @@ -59,12 +58,7 @@ def render_report( try: ret = reporter.report(morfs, outfile=outfile) if file_to_close is not None: - if sys.stdout.isatty(): - file_path = f"file://{os.path.abspath(output_path)}" - print_path = f"\033]8;;{file_path}\a{output_path}\033]8;;\a" - else: - print_path = output_path - msgfn(f"Wrote {reporter.report_type} to {print_path}") + msgfn(f"Wrote {reporter.report_type} to {output_path}") delete_file = False return ret finally: From 3e9205fc3a0c69976e3ca0afb9e43dd5677853b3 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 26 Apr 2023 21:26:28 -0400 Subject: [PATCH 15/30] build: fine-tune the messages we get from metacov --- igor.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/igor.py b/igor.py index a7c5f9635..f4c5d22f1 100644 --- a/igor.py +++ b/igor.py @@ -221,6 +221,10 @@ def do_combine_html(): cov.load() cov.combine() cov.save() + # A new Coverage to turn on messages. Better would be to have tighter + # control over message verbosity... + cov = coverage.Coverage(config_file="metacov.ini", messages=True) + cov.load() show_contexts = bool(os.environ.get('COVERAGE_DYNCTX') or os.environ.get('COVERAGE_CONTEXT')) cov.html_report(show_contexts=show_contexts) From 74b1758bb138355d5036631d8c92e7b0871339b2 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 26 Apr 2023 21:51:28 -0400 Subject: [PATCH 16/30] test: refactor and add a test of terminal link text --- coverage/html.py | 12 +++--------- coverage/misc.py | 12 ++++++++++++ tests/test_misc.py | 14 +++++++++++++- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/coverage/html.py b/coverage/html.py index 4e594343c..f11d85e1a 100644 --- a/coverage/html.py +++ b/coverage/html.py @@ -13,7 +13,6 @@ import re import shutil import string # pylint: disable=deprecated-module -import sys from dataclasses import dataclass from typing import Any, Dict, Iterable, List, Optional, Tuple, TYPE_CHECKING, cast @@ -23,7 +22,7 @@ from coverage.exceptions import NoDataError from coverage.files import flat_rootname from coverage.misc import ensure_dir, file_be_gone, Hasher, isolate_module, format_local_datetime -from coverage.misc import human_sorted, plural +from coverage.misc import human_sorted, plural, stdout_link from coverage.report import get_analysis_to_report from coverage.results import Analysis, Numbers from coverage.templite import Templite @@ -495,13 +494,8 @@ def index_file(self, first_html: str, final_html: str) -> None: index_file = os.path.join(self.directory, "index.html") write_html(index_file, html) - if sys.stdout.isatty(): - file_path = f"file://{os.path.abspath(index_file)}" - print_path = f"\033]8;;{file_path}\a{index_file}\033]8;;\a" - else: - print_path = index_file - - self.coverage._message(f"Wrote HTML report to {print_path}") + print_href = stdout_link(index_file, f"file://{os.path.abspath(index_file)}") + self.coverage._message(f"Wrote HTML report to {print_href}") # Write the latest hashes for next time. self.incr.write() diff --git a/coverage/misc.py b/coverage/misc.py index 8cefa12e0..061682ee5 100644 --- a/coverage/misc.py +++ b/coverage/misc.py @@ -386,3 +386,15 @@ def plural(n: int, thing: str = "", things: str = "") -> str: return thing else: return things or (thing + "s") + + +def stdout_link(text: str, url: str) -> str: + """Format text+url as a clickable link for stdout. + + If attached to a terminal, use escape sequences. Otherwise, just return + the text. + """ + if sys.stdout.isatty(): + return f"\033]8;;{url}\a{text}\033]8;;\a" + else: + return text diff --git a/tests/test_misc.py b/tests/test_misc.py index ba465cbd1..455a3bc1d 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -6,13 +6,14 @@ from __future__ import annotations import sys +from unittest import mock import pytest from coverage.exceptions import CoverageException from coverage.misc import file_be_gone from coverage.misc import Hasher, substitute_variables, import_third_party -from coverage.misc import human_sorted, human_sorted_items +from coverage.misc import human_sorted, human_sorted_items, stdout_link from tests.coveragetest import CoverageTest @@ -153,3 +154,14 @@ def test_human_sorted_items(words: str, ordered: str) -> None: oitems = [(k, v) for k in okeys for v in [1, 2]] assert human_sorted_items(items) == oitems assert human_sorted_items(items, reverse=True) == oitems[::-1] + + +def test_stdout_link_tty() -> None: + with mock.patch.object(sys.stdout, "isatty", lambda:True): + link = stdout_link("some text", "some url") + assert link == "\033]8;;some url\asome text\033]8;;\a" + + +def test_stdout_link_not_tty() -> None: + # Without mocking isatty, it reports False in a pytest suite. + assert stdout_link("some text", "some url") == "some text" From df1bf082f242cccdcb342000525bede537b95935 Mon Sep 17 00:00:00 2001 From: Kevin Brown-Silva Date: Thu, 27 Apr 2023 05:27:33 -0600 Subject: [PATCH 17/30] fix: source paths with trailing slashes causing inconsistent sources in XML report with relative_paths (#1608) * Added failing test for source with trailing slash This test is nearly identical to the one above it, with the only change being the source that is used. This may end up turning into a fixture instead if the tests end up being identical after the fix is made. * Strip trailing slash for relative source paths This fixes an issue introduced in 45cf7936ee605cfe06f7f5967a72a73198960120 where using `relative_files=True` and `src` with a trailing slash, the source inserted as `` in the XML report would also have a trailing slash. This also fixes an issue introduced in the same commit where an empty `` would be inserted as well for cases where the `src` has a trailing slash. --- coverage/xmlreport.py | 2 ++ tests/test_xml.py | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/coverage/xmlreport.py b/coverage/xmlreport.py index 2c8fd0cc1..b2180266d 100644 --- a/coverage/xmlreport.py +++ b/coverage/xmlreport.py @@ -69,6 +69,8 @@ def __init__(self, coverage: Coverage) -> None: if os.path.exists(src): if not self.config.relative_files: src = files.canonical_filename(src) + else: + src = src.rstrip(r"\/") self.source_paths.add(src) self.packages: Dict[str, PackageData] = {} self.xml_out: xml.dom.minidom.Document diff --git a/tests/test_xml.py b/tests/test_xml.py index 94b310e3e..0f2cff419 100644 --- a/tests/test_xml.py +++ b/tests/test_xml.py @@ -320,7 +320,7 @@ def test_accented_directory(self) -> None: def test_no_duplicate_packages(self) -> None: self.make_file( - "namespace/package/__init__.py", + "namespace/package/__init__.py", "from . import sample; from . import test; from .subpackage import test" ) self.make_file("namespace/package/sample.py", "print('package.sample')") @@ -489,6 +489,19 @@ def test_relative_source(self) -> None: elts = dom.findall(".//sources/source") assert [elt.text for elt in elts] == ["src"] + def test_relative_source_trailing_slash(self) -> None: + self.make_file("src/mod.py", "print(17)") + cov = coverage.Coverage(source=["src/"]) + cov.set_option("run:relative_files", True) + self.start_import_stop(cov, "mod", modfile="src/mod.py") + cov.xml_report() + + with open("coverage.xml") as x: + print(x.read()) + dom = ElementTree.parse("coverage.xml") + elts = dom.findall(".//sources/source") + assert [elt.text for elt in elts] == ["src"] + def compare_xml(expected: str, actual: str, actual_extra: bool = False) -> None: """Specialized compare function for our XML files.""" From 43085b9d5378ef343ac214fd15e8f7c2ceffa95f Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 27 Apr 2023 07:12:30 -0400 Subject: [PATCH 18/30] refactor: parametrize a test for #1608 --- CHANGES.rst | 6 ++++++ CONTRIBUTORS.txt | 1 + coverage/xmlreport.py | 6 +++--- tests/test_xml.py | 24 ++++++------------------ 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 5f89576ff..a001a9e6d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -20,6 +20,10 @@ development at the same time, such as 4.5.x and 5.0. Unreleased ---------- +- Fix: the XML report would have an incorrect ```` element when using + relative files and the source option ended with a slash (`issue 1541`_). + This is now fixed, thanks to `Kevin Brown-Silva `_. + - When the HTML report location is printed to the terminal, it's now a terminal-compatible URL, so that you can click the location to open the HTML file in your browser. Finishes `issue 1523`_ thanks to `Ricardo Newbery @@ -30,6 +34,8 @@ Unreleased wildcard changes in 7.x. Thanks, `Brian Grohe `_. .. _issue 1523: https://github.com/nedbat/coveragepy/issues/1523 +.. _issue 1541: https://github.com/nedbat/coveragepy/issues/1541 +.. _pull 1608: https://github.com/nedbat/coveragepy/pull/1608 .. _pull 1610: https://github.com/nedbat/coveragepy/pull/1610 .. _pull 1613: https://github.com/nedbat/coveragepy/pull/1613 diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index b02f7add9..bfdca0aae 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -101,6 +101,7 @@ Julian Berman Julien Voisin Justas Sadzevičius Kassandra Keeton +Kevin Brown-Silva Kjell Braden Krystian Kichewko Kyle Altendorf diff --git a/coverage/xmlreport.py b/coverage/xmlreport.py index b2180266d..82e60fc1f 100644 --- a/coverage/xmlreport.py +++ b/coverage/xmlreport.py @@ -67,10 +67,10 @@ def __init__(self, coverage: Coverage) -> None: if self.config.source: for src in self.config.source: if os.path.exists(src): - if not self.config.relative_files: - src = files.canonical_filename(src) - else: + if self.config.relative_files: src = src.rstrip(r"\/") + else: + src = files.canonical_filename(src) self.source_paths.add(src) self.packages: Dict[str, PackageData] = {} self.xml_out: xml.dom.minidom.Document diff --git a/tests/test_xml.py b/tests/test_xml.py index 0f2cff419..731053207 100644 --- a/tests/test_xml.py +++ b/tests/test_xml.py @@ -15,7 +15,7 @@ import pytest import coverage -from coverage import Coverage +from coverage import Coverage, env from coverage.exceptions import NoDataError from coverage.files import abs_file from coverage.misc import import_local_file @@ -476,28 +476,16 @@ def test_source_prefix(self) -> None: dom = ElementTree.parse("coverage.xml") self.assert_source(dom, "src") - def test_relative_source(self) -> None: + @pytest.mark.parametrize("trail", ["", "/", "\\"]) + def test_relative_source(self, trail: str) -> None: + if trail == "\\" and not env.WINDOWS: + pytest.skip("trailing backslash is only for Windows") self.make_file("src/mod.py", "print(17)") - cov = coverage.Coverage(source=["src"]) - cov.set_option("run:relative_files", True) - self.start_import_stop(cov, "mod", modfile="src/mod.py") - cov.xml_report() - - with open("coverage.xml") as x: - print(x.read()) - dom = ElementTree.parse("coverage.xml") - elts = dom.findall(".//sources/source") - assert [elt.text for elt in elts] == ["src"] - - def test_relative_source_trailing_slash(self) -> None: - self.make_file("src/mod.py", "print(17)") - cov = coverage.Coverage(source=["src/"]) + cov = coverage.Coverage(source=[f"src{trail}"]) cov.set_option("run:relative_files", True) self.start_import_stop(cov, "mod", modfile="src/mod.py") cov.xml_report() - with open("coverage.xml") as x: - print(x.read()) dom = ElementTree.parse("coverage.xml") elts = dom.findall(".//sources/source") assert [elt.text for elt in elts] == ["src"] From 81bee6c1766b265230c0c0a0cd03335519a1f8f4 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Thu, 27 Apr 2023 21:51:54 +0300 Subject: [PATCH 19/30] Add more contributors from the Git log --- CONTRIBUTORS.txt | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index bfdca0aae..beb94a0c5 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -23,6 +23,7 @@ Aron Griffis Artem Dayneko Arthur Deygin Arthur Rio +Asher Foa Ben Carlsson Ben Finney Benjamin Parzella @@ -33,8 +34,10 @@ Bradley Burns Brandon Rhodes Brett Cannon Brian Grohe +Bruno Oliveira Bruno P. Kinoshita Buck Evan +Buck Golemon Calen Pennington Carl Friedrich Bolz-Tereick Carl Gieringer @@ -43,6 +46,8 @@ Chris Adams Chris Jerdonek Chris Rose Chris Warrick +Christopher Pickering +Christian Clauss Christian Heimes Christine Lytwynec Christoph Blessing @@ -60,6 +65,7 @@ David Christian David MacIver David Stanek David Szotten +Dennis Sweeney Detlev Offenbach Devin Jeanpierre Dirk Thomas @@ -80,18 +86,22 @@ George-Cristian Bîrzan Greg Rogers Guido van Rossum Guillaume Chazarain +Holger Krekel Hugo van Kemenade Ian Moore Ilia Meerovich Imri Goldberg Ionel Cristian Mărieș Ivan Ciuvalschii +Jakub Wilk +Janakarajan Natarajan J. M. F. Tsang JT Olds Jerin Peter George Jessamyn Smith Joe Doherty Joe Jevnik +John Vandenberg Jon Chappell Jon Dufresne Joseph Tate @@ -100,17 +110,22 @@ Judson Neer Julian Berman Julien Voisin Justas Sadzevičius +Karthikeyan Singaravelan Kassandra Keeton Kevin Brown-Silva Kjell Braden Krystian Kichewko Kyle Altendorf Lars Hupfeldt Nielsen +Latrice Wilgus Leonardo Pistone Lewis Gaul Lex Berezhny Loïc Dachary Lorenzo Micò +Louis Heredero +Luis Nell +Łukasz Stolcman Manuel Jacob Marc Abramowitz Marc Gibbons @@ -119,6 +134,7 @@ Marcelo Trylesinski Marcus Cobden Marius Gedminas Mark van der Wal +Mariatta Martin Fuzzey Mathieu Kniewallner Matt Bachmann @@ -126,23 +142,30 @@ Matthew Boehm Matthew Desmarais Matus Valo Max Linke +Mayank Singhal Michael Krebs Michał Bultrowicz Michał Górny Mickie Betz Mike Fiedler +Min ho Kim Nathan Land +Naveen Srinivasan Naveen Yadav Neil Pilgrim +Nicholas Nadeau Nikita Bloshchanevich Nils Kattenbeck +Nikita Sobolev Noel O'Boyle +Oleg Höfling Oleh Krehel Olivier Grisel Ori Avtalion Pablo Carballo Pankaj Pandey Patrick Mezard +Pavel Tsialnou Peter Baughman Peter Ebden Peter Portante @@ -151,6 +174,7 @@ Reya B Ricardo Newbery Rodrigue Cloutier Roger Hu +Roland Illig Ross Lawley Roy Williams Russell Keith-Magee @@ -159,9 +183,11 @@ Sandra Martocchia Scott Belden Sebastián Ramírez Sergey B Kirpichev +Shantanu Sigve Tjora Simon Willison Stan Hu +Stanisław Pitucha Stefan Behnel Stephan Deibel Stephan Richter @@ -176,10 +202,13 @@ Teake Nutma Ted Wexler Thijs Triemstra Thomas Grainger +Timo Furrer Titus Brown +Tom Gurion Valentin Lab Ville Skyttä Vince Salvino +Wonwin McBrootles Xie Yanbo Yilei "Dolee" Yang Yury Selivanov From 23717cefa18bc1f15e83ca313268a02930a0409a Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 27 Apr 2023 16:02:34 -0400 Subject: [PATCH 20/30] docs: alphabetize the contributors --- CONTRIBUTORS.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index beb94a0c5..f03ceacbc 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -46,12 +46,12 @@ Chris Adams Chris Jerdonek Chris Rose Chris Warrick -Christopher Pickering Christian Clauss Christian Heimes Christine Lytwynec Christoph Blessing Christoph Zwerschke +Christopher Pickering Clément Pit-Claudel Conrad Ho Cosimo Lupo @@ -93,10 +93,10 @@ Ilia Meerovich Imri Goldberg Ionel Cristian Mărieș Ivan Ciuvalschii -Jakub Wilk -Janakarajan Natarajan J. M. F. Tsang JT Olds +Jakub Wilk +Janakarajan Natarajan Jerin Peter George Jessamyn Smith Joe Doherty @@ -132,9 +132,9 @@ Marc Gibbons Marc Legendre Marcelo Trylesinski Marcus Cobden +Mariatta Marius Gedminas Mark van der Wal -Mariatta Martin Fuzzey Mathieu Kniewallner Matt Bachmann @@ -155,8 +155,8 @@ Naveen Yadav Neil Pilgrim Nicholas Nadeau Nikita Bloshchanevich -Nils Kattenbeck Nikita Sobolev +Nils Kattenbeck Noel O'Boyle Oleg Höfling Oleh Krehel @@ -178,6 +178,7 @@ Roland Illig Ross Lawley Roy Williams Russell Keith-Magee +S. Y. Lee Salvatore Zagaria Sandra Martocchia Scott Belden @@ -197,7 +198,6 @@ Steve Leonard Steve Oswald Steve Peak Sviatoslav Sydorenko -S. Y. Lee Teake Nutma Ted Wexler Thijs Triemstra From 3344a78595f5158a7412b9a6c70ceb9a56df437b Mon Sep 17 00:00:00 2001 From: Marc Gibbons <1726961+marcgibbons@users.noreply.github.com> Date: Mon, 24 Apr 2023 12:35:12 -0600 Subject: [PATCH 21/30] tet: add tests to reproduce #1604 (#1609) --- tests/test_summary.py | 53 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tests/test_summary.py b/tests/test_summary.py index f532a7b1f..f2158c93f 100644 --- a/tests/test_summary.py +++ b/tests/test_summary.py @@ -142,6 +142,59 @@ def test_report_including(self) -> None: assert "mycode.py " in report assert self.last_line_squeezed(report) == "TOTAL 4 0 100%" + def test_report_include_relative_files_and_path(self) -> None: + """ + Test that when relative_files is True and a relative path to a module + is included, coverage is reported for the module. + + Ref: https://github.com/nedbat/coveragepy/issues/1604 + """ + self.make_mycode() + self.make_file(".coveragerc", """\ + [run] + relative_files = true + """) + self.make_file("submodule/mycode.py", "import mycode") + + cov = coverage.Coverage() + self.start_import_stop(cov, "submodule/mycode") + report = self.get_report(cov, include="submodule/mycode.py") + + # Name Stmts Miss Cover + # --------------------------------------- + # submodule/mycode.py 1 0 100% + # --------------------------------------- + # TOTAL 1 0 100% + + assert "submodule/mycode.py " in report + assert self.last_line_squeezed(report) == "TOTAL 1 0 100%" + + def test_report_include_relative_files_and_wildcard_path(self) -> None: + self.make_mycode() + self.make_file(".coveragerc", """\ + [run] + relative_files = true + """) + self.make_file("submodule/mycode.py", "import nested.submodule.mycode") + self.make_file("nested/submodule/mycode.py", "import mycode") + + cov = coverage.Coverage() + self.start_import_stop(cov, "submodule/mycode") + report = self.get_report(cov, include="*/submodule/mycode.py") + + # Name Stmts Miss Cover + # ------------------------------------------------- + # nested/submodule/mycode.py 1 0 100% + # submodule/mycode.py 1 0 100% + # ------------------------------------------------- + # TOTAL 2 0 100% + + reported_files = [line.split()[0] for line in report.splitlines()[2:4]] + assert reported_files == [ + "nested/submodule/mycode.py", + "submodule/mycode.py", + ] + def test_omit_files_here(self) -> None: # https://github.com/nedbat/coveragepy/issues/1407 self.make_file("foo.py", "") From ee6506f08e5de7e568751f78e8be82fc2a102ffe Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 19 Apr 2023 11:23:12 -0400 Subject: [PATCH 22/30] fix: specific files to include/omit should match even with relative files #1604. --- CHANGES.rst | 6 ++++++ coverage/files.py | 5 ++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index a001a9e6d..377cabc18 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -20,6 +20,10 @@ development at the same time, such as 4.5.x and 5.0. Unreleased ---------- +- Fix: with ``relative_files = true``, specifying a specific file to include or + omit wouldn't work correctly (`issue 1604`_). This is now fixed, with + testing help by `Marc Gibbons `_. + - Fix: the XML report would have an incorrect ```` element when using relative files and the source option ended with a slash (`issue 1541`_). This is now fixed, thanks to `Kevin Brown-Silva `_. @@ -35,7 +39,9 @@ Unreleased .. _issue 1523: https://github.com/nedbat/coveragepy/issues/1523 .. _issue 1541: https://github.com/nedbat/coveragepy/issues/1541 +.. _issue 1604: https://github.com/nedbat/coveragepy/issues/1604 .. _pull 1608: https://github.com/nedbat/coveragepy/pull/1608 +.. _pull 1609: https://github.com/nedbat/coveragepy/pull/1609 .. _pull 1610: https://github.com/nedbat/coveragepy/pull/1610 .. _pull 1613: https://github.com/nedbat/coveragepy/pull/1613 diff --git a/coverage/files.py b/coverage/files.py index 2a1177340..925d57723 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -209,9 +209,8 @@ def prep_patterns(patterns: Iterable[str]) -> List[str]: """ prepped = [] for p in patterns or []: - if p.startswith(("*", "?")): - prepped.append(p) - else: + prepped.append(p) + if not p.startswith(("*", "?")): prepped.append(abs_file(p)) return prepped From 1f5beeb706696f91955b68723fd8b8ffc7570f3c Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 28 Apr 2023 05:33:23 -0400 Subject: [PATCH 23/30] docs: prep for 7.2.4 --- CHANGES.rst | 11 ++++++++--- coverage/version.py | 4 ++-- doc/conf.py | 6 +++--- tox.ini | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 377cabc18..22ff98dfd 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -17,8 +17,14 @@ development at the same time, such as 4.5.x and 5.0. .. Version 9.8.1 — 2027-07-27 .. -------------------------- -Unreleased ----------- +.. scriv-start-here + +.. _changes_7-2-4: + +Version 7.2.4 — 2023-04-28 +-------------------------- + +PyCon 2023 sprint fixes! - Fix: with ``relative_files = true``, specifying a specific file to include or omit wouldn't work correctly (`issue 1604`_). This is now fixed, with @@ -45,7 +51,6 @@ Unreleased .. _pull 1610: https://github.com/nedbat/coveragepy/pull/1610 .. _pull 1613: https://github.com/nedbat/coveragepy/pull/1613 -.. scriv-start-here .. _changes_7-2-3: diff --git a/coverage/version.py b/coverage/version.py index d9f10f4cf..d878ebc1b 100644 --- a/coverage/version.py +++ b/coverage/version.py @@ -8,8 +8,8 @@ # version_info: same semantics as sys.version_info. # _dev: the .devN suffix if any. -version_info = (7, 2, 4, "alpha", 0) -_dev = 1 +version_info = (7, 2, 4, "final", 0) +_dev = 0 def _make_version( diff --git a/doc/conf.py b/doc/conf.py index f6310b577..f0b2d6e42 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -66,11 +66,11 @@ # @@@ editable copyright = "2009–2023, Ned Batchelder" # pylint: disable=redefined-builtin # The short X.Y.Z version. -version = "7.2.3" +version = "7.2.4" # The full version, including alpha/beta/rc tags. -release = "7.2.3" +release = "7.2.4" # The date of release, in "monthname day, year" format. -release_date = "April 6, 2023" +release_date = "April 28, 2023" # @@@ end rst_epilog = """ diff --git a/tox.ini b/tox.ini index ebc998162..e5a9db8c4 100644 --- a/tox.ini +++ b/tox.ini @@ -66,7 +66,7 @@ commands = - sphinx-build -b html -b linkcheck -aEnQW doc doc/_build/html [testenv:lint] -# PYVERSIONS +# Minimum of PYVERSIONS basepython = python3.7 deps = -r requirements/lint.pip From 90736643823bb2c6fa978ca30c054ac8848df318 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Fri, 28 Apr 2023 05:33:57 -0400 Subject: [PATCH 24/30] docs: sample HTML for 7.2.4 --- doc/sample_html/d_7b071bdc2a35fa80___init___py.html | 8 ++++---- doc/sample_html/d_7b071bdc2a35fa80___main___py.html | 8 ++++---- doc/sample_html/d_7b071bdc2a35fa80_cogapp_py.html | 8 ++++---- doc/sample_html/d_7b071bdc2a35fa80_makefiles_py.html | 8 ++++---- doc/sample_html/d_7b071bdc2a35fa80_test_cogapp_py.html | 8 ++++---- doc/sample_html/d_7b071bdc2a35fa80_test_makefiles_py.html | 8 ++++---- .../d_7b071bdc2a35fa80_test_whiteutils_py.html | 8 ++++---- doc/sample_html/d_7b071bdc2a35fa80_whiteutils_py.html | 8 ++++---- doc/sample_html/index.html | 8 ++++---- doc/sample_html/status.json | 2 +- 10 files changed, 37 insertions(+), 37 deletions(-) diff --git a/doc/sample_html/d_7b071bdc2a35fa80___init___py.html b/doc/sample_html/d_7b071bdc2a35fa80___init___py.html index a15b8decf..6351b32dd 100644 --- a/doc/sample_html/d_7b071bdc2a35fa80___init___py.html +++ b/doc/sample_html/d_7b071bdc2a35fa80___init___py.html @@ -66,8 +66,8 @@

^ index     » next       - coverage.py v7.2.3, - created at 2023-04-06 08:42 -0400 + coverage.py v7.2.4, + created at 2023-04-28 05:33 -0400