Skip to content
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

assert line in analysis.missing since coverage 7.6.2 #1896

Closed
sajith opened this issue Nov 19, 2024 · 6 comments
Closed

assert line in analysis.missing since coverage 7.6.2 #1896

sajith opened this issue Nov 19, 2024 · 6 comments
Labels
bug Something isn't working fixed

Comments

@sajith
Copy link

sajith commented Nov 19, 2024

Describe the bug

Running python -m coverage lcov -o coverage.lcov used to work just fine until coverage 7.6.1:

$ python -m coverage --version 
Coverage.py, version 7.6.1 with C extension
Full documentation is at https://coverage.readthedocs.io/en/7.6.1
$ python -m coverage lcov -o coverage.lcov
Wrote LCOV report to coverage.lcov

This doesn't work since 7.6,2:

$ pip install coverage==7.6.7
$ python -m coverage lcov -o coverage.lcov
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/path/to/project/.venv/lib64/python3.12/site-packages/coverage/__main__.py", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "/path/to/project/.venv/lib64/python3.12/site-packages/coverage/cmdline.py", line 970, in main
    status = CoverageScript().command_line(argv)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/project/.venv/lib64/python3.12/site-packages/coverage/cmdline.py", line 743, in command_line
    total = self.coverage.lcov_report(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/project/.venv/lib64/python3.12/site-packages/coverage/control.py", line 1277, in lcov_report
    return render_report(self.config.lcov_output, LcovReporter(self), morfs, self._message)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/project/.venv/lib64/python3.12/site-packages/coverage/report_core.py", line 62, in render_report
    ret = reporter.report(morfs, outfile=outfile)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/project/.venv/lib64/python3.12/site-packages/coverage/lcovreport.py", line 189, in report
    self.lcov_file(fname, fr, analysis, outfile)
  File "/path/to/project/.venv/lib64/python3.12/site-packages/coverage/lcovreport.py", line 221, in lcov_file
    lcov_arcs(fr, analysis, lines, outfile)
  File "/path/to/project/.venv/lib64/python3.12/site-packages/coverage/lcovreport.py", line 124, in lcov_arcs
    assert line in analysis.missing
           ^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

To Reproduce
How can we reproduce the problem? Please be specific. Don't link to a failing CI job. Answer the questions below:

  1. What version of Python are you using?

Python 3.9, 3.10, 3.11, and 3.12.

  1. What version of coverage.py shows the problem? The output of coverage debug sys is helpful.

Since coverage 7.6.2 up to the latest 7.6.7.

  1. What versions of what packages do you have installed? The output of pip freeze is helpful.
absl-py==2.1.0
backports-datetime-fromisoformat==1.0.0
black==24.10.0
cffi==1.15.0
click==8.1.7
contourpy==1.3.1
coverage==7.6.7
cycler==0.12.1
dataclasses-json==0.6.7
et_xmlfile==2.0.0
fonttools==4.55.0
grenml==1.0.0
immutabledict==4.2.1
iniconfig==2.0.0
isort==5.13.2
kiwisolver==1.4.7
lxml==4.9.4
marshmallow==3.23.1
matplotlib==3.9.2
mip==1.14.2
mypy-extensions==1.0.0
networkx==3.4.2
numpy==2.1.3
openpyxl==3.1.5
ortools==9.11.4210
packaging==24.2
pandas==2.2.3
pathspec==0.12.1
pillow==11.0.0
platformdirs==4.3.6
pluggy==1.5.0
protobuf==5.26.1
prtpy==0.8.3
pycparser==2.22
pydot==3.0.2
pyparsing==3.2.0
pytest==8.3.3
pytest-cov==6.0.0
pytest-sugar==1.0.0
python-dateutil==2.9.0.post0
pytz==2024.2
ruff==0.0.285
scipy==1.14.1
sdx-datamodel @ git+https://github.com/atlanticwave-sdx/datamodel@d9ac85a9fdd1c87aedc56001859fc5fe543b365a
-e git+https://github.com/atlanticwave-sdx/pce@eb64f3f93fe90e16a5da80b75ce44de0e9f4f6ff#egg=sdx_pce
six==1.16.0
termcolor==2.5.0
typing-inspect==0.9.0
typing_extensions==4.12.2
tzdata==2024.2
  1. What code shows the problem? Give us a specific commit of a specific repo that we can check out. If you've already worked around the problem, please provide a commit before that fix.

I am trying to send coverage report in LCOV format to coveralls.io from https://github.com/atlanticwave-sdx/pce (please excuse the prototype-iness), and running python -m coverage lcov -o coverage.lcov from CI jobs fails with a backtrace, as described above. This is reproducible in a local setup also. This library uses a dependency with a C extension (ortools), and I suspect that could be the problem, because other "pure" Python projects I work on are not affected.

Using coverage 7.6.1 is the workaround.

  1. What commands should we run to reproduce the problem? Be specific. Include everything, even git clone, pip install, and so on. Explain like we're five!

Do this (assuming bash and Linux):

$ git clone https://github.com/atlanticwave-sdx/pce
$ cd pce
$ python3.12 -m venv .venv --upgrade-deps
$ source .venv/bin/activate
$ pip install tox
$ tox
$ python -m coverage lcov -o coverage.lcov

Expected behavior

Coverage should be able to produce an LCOV file without crashing.

Additional context

Unsure, sorry!

@sajith sajith added the bug Something isn't working label Nov 19, 2024
sajith added a commit to atlanticwave-sdx/pce that referenced this issue Nov 19, 2024
@nedbat
Copy link
Owner

nedbat commented Nov 19, 2024

Thanks, I can reproduce the problem. Now to understand why...

@sajith
Copy link
Author

sajith commented Nov 19, 2024

@nedbat Thank you for looking into this. Just a heads-up, in case you need to use the repository in question again: I just merged a work-around (which is: using coverage 7.6.1) in the main branch there.

@nedbat
Copy link
Owner

nedbat commented Nov 19, 2024

A simple case, and the HTML report shows confusion about it too:
image

@vser1
Copy link

vser1 commented Nov 22, 2024

Note also that the assert fires on

for i in(1, 2, 3, 4):
    if True or False:
        print("foo")
    continue

(see #198)
As the continue is not marked as covered and the assert fails.

@nedbat
Copy link
Owner

nedbat commented Nov 23, 2024

Fixed in commit 2ace7a2.

@nedbat nedbat added the fixed label Nov 23, 2024
@nedbat nedbat closed this as completed Nov 23, 2024
@nedbat
Copy link
Owner

nedbat commented Nov 24, 2024

This is now released as part of coverage 7.6.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

3 participants