question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

coverage with tox

See original GitHub issue

I followed your youtube video as a guide in this repository and I put this in my pyproject.toml:

[tool.pytest.ini_options]
addopts = "--cov=src/be8bbbce/components --cov-branch"
testpaths = [
    "tests",
]

When I run pytest, I see my statement and branch coverage the way I want, but when I run tox, it says I have 0% statement coverage and doesn’t show any branch coverage.

How do I get tox to show the same coverage as pytest?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mCodingLLCcommented, Oct 22, 2021

Thanks @pyrkamarcin I think either one of those solutions works great depending on what you want. @beauxq I think that should solve your issue so I’ll go ahead and close this.

0reactions
beauxqcommented, Oct 23, 2021

I figured it out when I remembered 7:59 in the youtube video.

Because I was trying to get coverage on only 1 submodule of my package, I was giving it a directory of where to look: --cov=src/be8bbbce/components

But it’s not running code in that directory. It’s running a link in …lib/python/site-packages

I think I tried --cov=be8bbbce/components at some point and found it didn’t work, but after I remembered it’s running the installed package, I tried --cov=be8bbbce.components and it worked.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tox — pytest-cov 4.0.0 documentation - Read the Docs
An usual problem users have is that pytest-cov will erase the previous coverage data by default, thus if you run tox with multiple...
Read more >
Testing better with coverage and tox
coverage. This tool tells you what parts of your code are actually getting executed by the test suite. It can't guarantee that you're...
Read more >
Making py.test, coverage and tox work together: __init__.py in ...
I'm having a weird problem with tox , py.test , coverage and pytest-cov : when py.test with the --cov option is launched from...
Read more >
Platform Dependent Python Coverage Test with Tox
When testing Python programs, coverage.py is often used in measuring code coverage, and enforcing 100% code coverage is regarded as a good ...
Read more >
tox + coverage : getting combined python code ... - gists · GitHub
tox + coverage : getting combined python code coverage. - 1_tox.ini. ... [tox]. envlist = begin,py{26,27,33},end. [testenv]. deps=coverage. commands =.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found