summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2022-12-23 15:47:15 -0500
committerNed Batchelder <ned@nedbatchelder.com>2022-12-23 16:06:46 -0500
commitda1b282d3b39a6232e4cb798838389f7b16a0795 (patch)
tree684d42ad41ea4c3c2f0879c51804078eaadcece1
parentd327a70d9b81833c0ce22f2046b1d93892c1e72d (diff)
downloadpython-coveragepy-git-da1b282d3b39a6232e4cb798838389f7b16a0795.tar.gz
fix: also look into .whl files for source
-rw-r--r--CHANGES.rst4
-rw-r--r--coverage/files.py4
-rw-r--r--tests/test_files.py3
3 files changed, 9 insertions, 2 deletions
diff --git a/CHANGES.rst b/CHANGES.rst
index 026ffe07..38c49d69 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -20,6 +20,9 @@ development at the same time, such as 4.5.x and 5.0.
Unreleased
----------
+- When checking if a file mapping resolved to a file that exists, we weren't
+ considering files in .whl files. This is now fixed, closing `issue 1511`_.
+
- File pattern rules were too strict, forbidding plus signs and curly braces in
directory and file names. This is now fixed, closing `issue 1513`_.
@@ -29,6 +32,7 @@ Unreleased
- The PyPy wheel now installs on PyPy 3.7, 3.8, and 3.9, closing `issue 1510`_.
.. _issue 1510: https://github.com/nedbat/coveragepy/issues/1510
+.. _issue 1511: https://github.com/nedbat/coveragepy/issues/1511
.. _issue 1512: https://github.com/nedbat/coveragepy/issues/1512
.. _issue 1513: https://github.com/nedbat/coveragepy/issues/1513
diff --git a/coverage/files.py b/coverage/files.py
index 05c98eec..33964960 100644
--- a/coverage/files.py
+++ b/coverage/files.py
@@ -160,7 +160,7 @@ def zip_location(filename):
name is in the zipfile.
"""
- for ext in ['.zip', '.egg', '.pex']:
+ for ext in ['.zip', '.whl', '.egg', '.pex']:
zipbase, extension, inner = filename.partition(ext + sep(filename))
if extension:
zipfile = zipbase + ext
@@ -473,7 +473,7 @@ class PathAliases:
if not exists(new):
self.debugfn(
f"Rule {original_pattern!r} changed {path!r} to {new!r} " +
- f"which doesn't exist, continuing"
+ "which doesn't exist, continuing"
)
continue
self.debugfn(
diff --git a/tests/test_files.py b/tests/test_files.py
index 29bd9a0d..54c91628 100644
--- a/tests/test_files.py
+++ b/tests/test_files.py
@@ -86,6 +86,7 @@ class FilesTest(CoverageTest):
("a/b/c/foo.py", "a/b/c/foo.py", True),
("a/b/c/foo.py", "a/b/c/bar.py", False),
("src/files.zip", "src/files.zip/foo.py", True),
+ ("src/files.whl", "src/files.whl/foo.py", True),
("src/files.egg", "src/files.egg/foo.py", True),
("src/files.pex", "src/files.pex/foo.py", True),
("src/files.zip", "src/morefiles.zip/foo.py", False),
@@ -93,6 +94,8 @@ class FilesTest(CoverageTest):
]
)
def test_source_exists(self, to_make, to_check, answer):
+ # source_exists won't look inside the zipfile, so it's fine to make
+ # an empty file with the zipfile name.
self.make_file(to_make, "")
assert files.source_exists(to_check) == answer