-
Notifications
You must be signed in to change notification settings - Fork 211
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
Misleading subprocess coverage with relative path --cov #282
Comments
It appears you have found a quirk in coveragepy. The "source" (whatever you pass to Personally I consider your particular configuration an antipattern - you should avoid using paths. That configuration will be broken when you change from |
If using a path is an antipattern..... It's explicitly documented to be a filesystem path. Also in
It's not at all documented as a bare option, as far as I can tell. This particular case came up with a colleague wanting to test the coverage of some subset of a module rather than everything. At the very least the problem should be listed in the caveats of subprocess, or detected and warned about. |
|
If
--cov
is passed relative, not absolute, and a subprocess is run in a different directory, then the subprocess coverage will be silently ignored. Example:test_subprocess_coverage.py
Output:
I think I understand the reasons why, that the path is passed through in the environment relative so the child coverage has no idea what is being checked - but the fact that it's silently failing has bitten us several times. (instantiating child jobs as in-process function calls is something we are slowly working towards, but is a long ways off).
I'd imagine that just making the environment variable absolute (guessing here) would solve this for my case, but imagine might cause issues with cluster-distributed testing where the code might have been copied somewhere different? In which case maybe there is a similar bug when cluster-distributed and passing in an absolute path....
Edit: A slightly similar issue seems to have been dealt with for the
.coveragerc
file in #94/#95The text was updated successfully, but these errors were encountered: