coveragepy icon indicating copy to clipboard operation
coveragepy copied to clipboard

Says 98%, no "red line" on the 2%, bug!

Open JamesFraserLogan opened this issue 1 year ago • 2 comments

Describe the bug A clear and concise description of the bug.

My code has 100% coverage. I re-ran coverage, it says 98%. When I do coverage html and look at the web page, there are no untested statements and there are no "red lines". I can't have the "1 missing" show up when I click it.

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?

3.11.5

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

5.5

  1. What versions of what packages do you have installed? The output of pip freeze is helpful. anyio==4.0.0 argon2-cffi==23.1.0 argon2-cffi-bindings==21.2.0 arrow==1.2.3 astroid==2.15.8 asttokens==2.4.0 async-lru==2.0.4 attrs==23.1.0 Babel==2.12.1 backcall==0.2.0 beautifulsoup4==4.12.2 black==23.9.1 bleach==6.0.0 certifi==2023.7.22 cffi==1.16.0 charset-normalizer==3.2.0 click==8.1.7 colorama==0.4.6 comm==0.1.4 coverage==5.5 debugpy==1.8.0 decorator==5.1.1 defusedxml==0.7.1 dill==0.3.7 et-xmlfile==1.1.0 executing==1.2.0 fastjsonschema==2.18.0 fqdn==1.5.1 idna==3.4 iniconfig==2.0.0 ipykernel==6.25.2 ipython==8.15.0 isoduration==20.11.0 isort==5.12.0 jedi==0.19.0 Jinja2==3.1.2 json5==0.9.14 jsonpointer==2.4 jsonschema==4.19.1 jsonschema-specifications==2023.7.1 jupyter-events==0.7.0 jupyter-lsp==2.2.0 jupyter_client==8.3.1 jupyter_core==5.3.2 jupyter_server==2.7.3 jupyter_server_terminals==0.4.4 jupyterlab==4.0.6 jupyterlab-pygments==0.2.2 jupyterlab_server==2.25.0 lazy-object-proxy==1.9.0 MarkupSafe==2.1.3 matplotlib-inline==0.1.6 mccabe==0.7.0 mistune==3.0.1 mypy-extensions==1.0.0 nbclient==0.8.0 nbconvert==7.8.0 nbformat==5.9.2 nest-asyncio==1.5.8 notebook_shim==0.2.3 numpy==1.26.0 openpyxl==3.1.2 overrides==7.4.0 packaging==23.1 pandas==2.1.1 pandocfilters==1.5.0 parso==0.8.3 pathspec==0.11.2 pickleshare==0.7.5 platformdirs==3.10.0 pluggy==1.3.0 prometheus-client==0.17.1 prompt-toolkit==3.0.39 psutil==5.9.5 pure-eval==0.2.2 pycparser==2.21 Pygments==2.16.1 pylint==2.17.6 pytest==7.4.2 pytest-cov==4.1.0 python-dateutil==2.8.2 python-json-logger==2.0.7 pytz==2023.3.post1 pywin32==306 pywinpty==2.0.11 PyYAML==6.0.1 pyzmq==25.1.1 readme-coverage-badger==0.1.2 referencing==0.30.2 requests==2.31.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 rpds-py==0.10.3 Send2Trash==1.8.2 six==1.16.0 sniffio==1.3.0 soupsieve==2.5 stack-data==0.6.2 terminado==0.17.1 tinycss2==1.2.1 toml==0.10.2 tomlkit==0.12.1 tornado==6.3.3 traitlets==5.10.1 tzdata==2023.3 uri-template==1.3.0 urllib3==2.0.5 wcwidth==0.2.6 webcolors==1.13 webencodings==0.5.1 websocket-client

  2. 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.

Not possible. Restricted.

  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!

pipenv shell pytest --cov coverage report coverage html

Expected behavior A clear and concise description of what you expected to happen.

100% coverage shown for all statements tested.

Additional context Add any other context about the problem here.

It showed 100%, then I installed readme-coverage-badger and it would only show 98%. I also did some changes to the code, but they were minuscule.

It now pulls a warning: DeprecationWarning: currentThread() is deprecated, use current_thread() instead self.thread = self.threading.currentThread()

And in line 223 of pytracer.py you are indeed using self.threading.currentThread.

Edit: able to recreate on demand. I pushed to repo, and redeployed in wsl. As soon as the coverage badger is installed, the bug occurs. To repeat, I had an old version in wsl. I pushed my new version to repo, and pulled it into wsl and re-ran "pytest --cov". It worked 100%.

I then did a "pipenv sync" to install the coverage badger (readme-coverage-badger). Then I reran "pytest --cov" and boom, the bug happened on demand.

The error message makes it sound like coverage is to blame, but I think it's probably readme-coverage-badger.

Update: I can kill the bug by uninstalling readme-coverage-badger, then deleting .coverage and re-running "pytest --cov". 100% coverage again!

JamesFraserLogan avatar Sep 28 '23 21:09 JamesFraserLogan

I've never used readme-coverage-badger, but at a glance, I don't see how it could change your coverage. Have you tried asking them about it? Also, you say you are using coverage 5.5, which is quite old. Is this still a problem with the latest version?

I know you said your code is private. Can you create a small reproducer that you can share?

nedbat avatar Sep 29 '23 01:09 nedbat

Hi Nedbat,

Thank you for the reply. I am quite surprised it is using an old version. It looks like the bug is 100% due to this badger package. Sorry for the false alarm!

I will open an issue with them and let them know. Thanks for your time!

On Thu, Sep 28, 2023, 7:26 PM Ned Batchelder @.***> wrote:

I've never used readme-coverage-badger, but at a glance, I don't see how it could change your coverage. Have you tried asking them about it? Also, you say you are using coverage 5.5, which is quite old. Is this still a problem with the latest version?

— Reply to this email directly, view it on GitHub https://github.com/nedbat/coveragepy/issues/1686#issuecomment-1740188306, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIY77OKWP2FYBZLQD6ON5IDX4YPVPANCNFSM6AAAAAA5LSMJAQ . You are receiving this because you authored the thread.Message ID: @.***>

JamesFraserLogan avatar Sep 29 '23 03:09 JamesFraserLogan