-
-
Notifications
You must be signed in to change notification settings - Fork 433
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
Support reporting filenames relative to PYTHONPATH #1415
Comments
Hi, sorry it's taken me so long to get to this. I'm making some improvements (described in #991, which isn't really about slash direction) that might make this easier. I have a project using src layout (scriv). It's coverage measurement includes this
Do you use |
Thanks for your reply! It helped a lot. As things are, I don't use In response to your suggestion, I've added the following to my [tool.coverage.paths]
source = ["src", "*/site-packages"] and adjusted my coverage setup to invoke
The result is that the reported paths now look like the following:
which I consider to be acceptable. That's with So this is at least a partial solution to my problem, and I'd be happy enough to take it for now. Some things which might make it nicer:
|
In case anyone else stumbles upon this: I just discovered the existence of It basically allows to replace the separate commands with a single |
Just found this after reporting #1674, which is slightly more general compared to this request, namely: Support reporting filenames relative to any configured base directory, and/or support applying arbitrary transformations to paths in a final post-processing step. |
Is your feature request related to a problem? Please describe.
I run coverage on pytest under tox in my project, and I'm trying to move to a src layout. That means that a simple import of my package will no longer find it in the current directory, but rather in the venv where tox installed it.
When I do that, then suddenly, I start getting really long filenames in the coverage report:
and so on.
Describe the solution you'd like
I want the first part of the path to be stripped off, leaving only the module name.
Something like
I don't understand why that doesn't work already. It seems that the
PythonFileReporter
tries to generate a name based on the module's__name__
:but for some reason, this code doesn't engage for me, and I just end up with the long path name.
Describe alternatives you've considered
I thought that maybe
relative_files = true
would help here, but a quick read through the source seems to indicate that this is about making filenames relative to the current working directory (which is as they get reported, indeed).Additional context
Here's some relevant
pyproject.toml
fragments:The text was updated successfully, but these errors were encountered: