-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure source dirs are absolute #681
base: master
Are you sure you want to change the base?
Conversation
280d589
to
42882db
Compare
This `COV_CORE_SOURCE` environment variable is key for making sure that child processes continue computing code coverage. However, there's no guarantee that child processes start in the same directory as their parent process, which screws up coverage reporting if you're using relative paths for coverage sources. The fix is to make sure we're dealing with absolute paths. This is a little tricky to get right, because sources can include both dirs and packages. This fixes pytest-dev#465
42882db
to
5290b0f
Compare
# Unfortunately, coverage.py doesn't provide a mechanism | ||
# for unambiguously specifying source_dirs, so we have to detect if a source is | ||
# a directory or a package by looking in the filesystem: https://github.com/nedbat/coveragepy/issues/1942. | ||
os.path.abspath(source) # noqa: PTH100 # see note below for why we're using `os.path.abspath` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is the note below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://github.com/pytest-dev/pytest-cov/blob/v6.1.0/src/pytest_cov/engine.py#L120-L121. Happy to remove this if it's no longer applicable.
@ionelmc, are we willing to depend on the newly released coveragepy 7.8.0? It includes a new |
Yes, why not, try using source_dirs. There will always be older pytest-cov releases for older coveragepy. |
This
COV_CORE_SOURCE
environment variable is key for making sure that child processes continue computing code coverage. However, there's no guarantee that child processes start in the same directory as their parent process, which screws up coverage reporting if you're using relative paths for coverage sources. The fix is to make sure we're dealing with absolute paths.This is a little tricky to get right, because sources can include both dirs and packages.
This fixes #465.