Skip to content

Commit da1b282

Browse files
committed
fix: also look into .whl files for source
1 parent d327a70 commit da1b282

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

CHANGES.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ development at the same time, such as 4.5.x and 5.0.
2020
Unreleased
2121
----------
2222

23+
- When checking if a file mapping resolved to a file that exists, we weren't
24+
considering files in .whl files. This is now fixed, closing `issue 1511`_.
25+
2326
- File pattern rules were too strict, forbidding plus signs and curly braces in
2427
directory and file names. This is now fixed, closing `issue 1513`_.
2528

@@ -29,6 +32,7 @@ Unreleased
2932
- The PyPy wheel now installs on PyPy 3.7, 3.8, and 3.9, closing `issue 1510`_.
3033

3134
.. _issue 1510: https://github.com/nedbat/coveragepy/issues/1510
35+
.. _issue 1511: https://github.com/nedbat/coveragepy/issues/1511
3236
.. _issue 1512: https://github.com/nedbat/coveragepy/issues/1512
3337
.. _issue 1513: https://github.com/nedbat/coveragepy/issues/1513
3438

coverage/files.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def zip_location(filename):
160160
name is in the zipfile.
161161
162162
"""
163-
for ext in ['.zip', '.egg', '.pex']:
163+
for ext in ['.zip', '.whl', '.egg', '.pex']:
164164
zipbase, extension, inner = filename.partition(ext + sep(filename))
165165
if extension:
166166
zipfile = zipbase + ext
@@ -473,7 +473,7 @@ def map(self, path, exists=source_exists):
473473
if not exists(new):
474474
self.debugfn(
475475
f"Rule {original_pattern!r} changed {path!r} to {new!r} " +
476-
f"which doesn't exist, continuing"
476+
"which doesn't exist, continuing"
477477
)
478478
continue
479479
self.debugfn(

tests/test_files.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,16 @@ def test_relative_dir_for_root(self, curdir, sep):
8686
("a/b/c/foo.py", "a/b/c/foo.py", True),
8787
("a/b/c/foo.py", "a/b/c/bar.py", False),
8888
("src/files.zip", "src/files.zip/foo.py", True),
89+
("src/files.whl", "src/files.whl/foo.py", True),
8990
("src/files.egg", "src/files.egg/foo.py", True),
9091
("src/files.pex", "src/files.pex/foo.py", True),
9192
("src/files.zip", "src/morefiles.zip/foo.py", False),
9293
("src/files.pex", "src/files.pex/zipfiles/files.zip/foo.py", True),
9394
]
9495
)
9596
def test_source_exists(self, to_make, to_check, answer):
97+
# source_exists won't look inside the zipfile, so it's fine to make
98+
# an empty file with the zipfile name.
9699
self.make_file(to_make, "")
97100
assert files.source_exists(to_check) == answer
98101

0 commit comments

Comments
 (0)