diff --git a/CHANGES.rst b/CHANGES.rst index 026ffe071..38c49d698 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 05c98eecc..33964960f 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 @@ def map(self, path, exists=source_exists): 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 29bd9a0d0..54c916287 100644 --- a/tests/test_files.py +++ b/tests/test_files.py @@ -86,6 +86,7 @@ def test_relative_dir_for_root(self, curdir, sep): ("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 @@ def test_relative_dir_for_root(self, curdir, sep): ] ) 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