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

Layout detection confused #648

Closed
robsdedude opened this issue Jul 18, 2024 · 1 comment
Closed

Layout detection confused #648

robsdedude opened this issue Jul 18, 2024 · 1 comment

Comments

@robsdedude
Copy link

Summary

I've been struggling with CoverageWarning: No data was collected. in a src layout project.
It boiled down to the tool incorrectly discovering the layout of my project.

Reproducer

# clone this repo v5.0.0
git clone --depth 1 --branch v5.0.0 git@github.com:pytest-dev/pytest-cov.git
cd pytest-cov

# create a venv with tox installed
python -m venv venv
source venv/bin/activate
pip install tox

cd examples/src-layout/

# run tox and notice how the report contains coverage of `src/example/__init__.py`
tox

# now create an empty folder that looks like it could be the package under test and run tox again
# this time, you'll notice that coverage data for coverage of `src/example/__init__.py` is missing
mkdir example
tox

I'm suspecting that's because the tool is thinking the folder example might contain the package while in reality src/example does. But I'm not 100% sure on this.

You might be wondering if this behavior is even a problem and why on earth I ended up having a folder with the name of my library in the root while using a src layout. It's surprisingly easy to end up in this situation when using git. The library I've been working on used to have an ad-hoc layout and still has on the LTS branch. However, it's using the src layout on the dev branch. Now git doesn't care about empty folders. So when you check out the LTS branch and then the dev branch, you're left with this really hard to debug situation 😇

@ionelmc
Copy link
Member

ionelmc commented Sep 15, 2024

This can be worked around by using an adequate coverage configuration. See b0e1e91 for example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants