Skip to content

Commit

Permalink
fix: also look into .whl files for source
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Dec 23, 2022
1 parent d327a70 commit da1b282
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Expand Up @@ -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`_.

Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions coverage/files.py
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions tests/test_files.py
Expand Up @@ -86,13 +86,16 @@ 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),
("src/files.pex", "src/files.pex/zipfiles/files.zip/foo.py", True),
]
)
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

Expand Down

0 comments on commit da1b282

Please sign in to comment.