-
-
Notifications
You must be signed in to change notification settings - Fork 428
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
IndexError: list index out of range on coverage lcov #1362
Comments
Thanks. Can you link us to the specific code you were measuring, and how you ran the tests/coverage? |
Hi @nedbat . I can't link to the specific code, it's a private repo. But the file that is causing the error is listed above. I was measuring coverage and generating the report using the following command |
I added some debug statements to print the covered value and the len(source_lines). Here is the output.
For some reason, Can you point me to where The source_file does in fact have 82 lines, not sure why it's getting
values in the analysis. Other context, this was previously working fine. Only changes here, was this class was broken up into multiple classes in different files, and now the |
@nedbat any idea about this? Can we at least handle the invalid index in the loop? |
This looks like a problem where line numbers from one frame are misattributed to another frame. I'm not going to fix it by checking the length of the list, because there's no reason it's limited to numbers that are too large. The wrong-frame numbers could be within the valid range of line numbers. We have to figure out why they are happening. Can you try running coverage with the |
Feel free to re-open this if you get more information. |
Describe the bug
I'm running coverage lcov and getting the following error:
IndexError: list index out of range
To Reproduce
How can we reproduce the problem? Please be specific. Don't link to a failing CI job. Answer the questions below:
3.10.4
coverage debug sys
is helpful.pip freeze
is helpfulI had it print the lines that it's hitting the index error on, it's consistently this code:
pytest --cov=app tests && coverage lcov
Expected behavior
I expect it to write to the lcov file without error
Additional context
if I add this code here I'm able to avoid the error.
For some reason
analysis.executed
is getting a value that is > len(source_lines) from my code.The text was updated successfully, but these errors were encountered: