-
-
Notifications
You must be signed in to change notification settings - Fork 447
Difference between coverage results with source specifies full dir instead of module name #426
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
Comments
Original comment by Loic Dachary (Bitbucket: dachary, GitHub: dachary) I tried to reproduce the problem with a foo module containing a single a.py file
With the following we have 50% coverage and that is to be expected:
Changing the file to import the module after starting coverage there is 100% coverage:
@atodorov am I missing something ? Note that this is with coverage master (i.e. > 4.2) and it could be that things evolved for the best since 4.0 ;-) |
Original comment by Alexander Todorov (Bitbucket: atodorov, GitHub: atodorov) @dachary I don't think your comment is related to the originally reported issue. If you take a look at the PR I've linked above you will see that I import all modules I want to cover after coverage has been enabled. My problem was the way in which the source path was specified. However I don't have the time to investigate and see how things are with 4.x |
Original comment by Loic Dachary (Bitbucket: dachary, GitHub: dachary) @atodorov I apologize for the confusion. Your fix look right: the source argument is a list of directories. If you specify pyanaconda instead of the full path to the directory it will only work as expected if pyanaconda is a subdirectory of your current working directory. Am I making sense this time ? |
Original comment by Loic Dachary (Bitbucket: dachary, GitHub: dachary) :-D I'm not a native english speaker, do you have a wording in mind to update the documentation ? I'd be happy to create a pull request with it. |
Original comment by Loic Dachary (Bitbucket: dachary, GitHub: dachary) @nedbat re-reading the documentation I see it reads directories or package names but I'm not sure in which case using a packaging name makes a difference ? |
Original comment by Loic Dachary (Bitbucket: dachary, GitHub: dachary) The --source is split into source and source_pkgs variables depending. It is then used to set source_match and source_pkgs_match to figure out if a source should be taken into account during the run. After the run and before saving the data to .coverage, the --source is used again to find which files were never executed. But the find_python_files does not know how to iterate over the files of a package. It only knows about listing the files in a directory. This difference between directories and packages in the --source argument should be documented. Or maybe this should be considered a bug and there should be no difference between files and modules. |
Original comment by Loic Dachary (Bitbucket: dachary, GitHub: dachary) @atodorov Here is a tentative fix so there is no difference between directories and modules https://bitbucket.org/ned/coveragepy/pull-requests/122/make-source-module-do-the-same-as-source/diff The alternative would be to document the difference. What do you think ? |
Do I understand this correctly? This bug is about a difference between source=dir and source=pkg, and the difference is that with source=dir, coverage will find completely unexecuted files, but with source=pkg, it will not. Right? |
make --source module do the same as --source directory #426 The --source argument can either be a module or a directory. The user close #426 → <<cset ed784d8f334e (bb)>> |
This was shipped in 4.3.2. |
Originally reported by Alexander Todorov (Bitbucket: atodorov, GitHub: atodorov)
Anaconda, the Fedora Linux installer supports coverage collection via the API interface. If you boot with
inst.debug
then the main file/usr/sbin/anaconda
will initialize coverage as one of the first things it does.The results are 105 files measured, which is short of 19 files which are also present in the pyanaconda module. OTOH if the source path is specified as the full path (e.g.
/usr/lib64/python3.4/site-packages/pyanaconda
) then all files inside are included in the coverage data. See:rhinstaller/anaconda#397
I've tried to reproduce locally with the same directory structure (but not the same code) and was not able to. I will keep trying so it's easier to reproduce and easier to debug/fix.
The text was updated successfully, but these errors were encountered: