Repository navigation
Conversation
…rrectly
When using relative_files=true, the auto-generated path mapping rules
used a regex pattern that could match paths anywhere, not just from the
start. This caused paths like "pkg/features/templates.py" to incorrectly
match a rule generated for "features/templates.py", resulting in lost
coverage data during combine operations.
The fix changes the auto-generated regex from:
^(.*[\\/])?{dir1}[\\/] (matches anywhere)
to:
^{dir1}[\\/] (anchored to start)
This ensures that nested directories with the same name as a top-level
directory are not incorrectly collapsed during coverage combine.
Fixes coveragepy#2072
dephiros
force-pushed
the
fix-issue-2072
branch
from
August 26, 2026 10:58
2827047 to
e2fdd2d
Compare
Author
|
@nedbat , I know you are busy but want to check in with you for a review 🙏 |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When using
relative_files=true, the auto-generated path mapping rules used a regex pattern^(.*[\\/])?{dir1}[\\/]that could match directory names anywhere in a path, not just from the start. This caused paths likepkg/features/templates.pyto incorrectly match a rule generated forfeatures/templates.py, resulting in lost coverage data during combine operations.The Problem
For example, with two files:
features/templates.pypkg/features/templates.pyThe auto-generated rule for
features/would use regex^(.*[\\/])?features[\\/], which incorrectly matchespkg/features/templates.pybecause(.*[\\/])?allows any prefix.The Fix
Changed the auto-generated regex from:
to:
This ensures that nested directories with the same name as a top-level directory are not incorrectly collapsed during coverage combine.
Testing
test_nested_directories_same_namethat verifies the fixFixes #2072