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

Create Way to force package even if filepath exists #268

Closed
nedbat opened this issue Sep 25, 2013 · 4 comments · Fixed by #1026, CSCfi/oidc-client#35 or CSCfi/beacon-python#162
Closed
Labels
bug Something isn't working fixed

Comments

@nedbat
Copy link
Owner

nedbat commented Sep 25, 2013

Originally reported by Donald Stufft (Bitbucket: dstufft, GitHub: dstufft)


When using tox to run tests the preferred way to run tests creates throw away virtual environments and installs the package to be tested into them. This means that the code to be running is actually inside .tox/venvname/lib/pythonX.Y/site-packages/library.

Normally coverage.py could support this BUT when doing --source library it sees the library/ directory in the current directory (which isn't being used) and doesn't do the package resolution. This leads to 0% coverage reports always when using tox. It would be great if there was a way to say "No really this is a package".


@nedbat nedbat added major bug Something isn't working labels Jun 23, 2018
@blueyed
Copy link
Contributor

blueyed commented Oct 30, 2018

What about supporting a pkg: prefix?

Or allowing to specify source_pkgs (used internally) directly?

For reference, the code is:

for src in config.source or []:
if os.path.isdir(src):
self.source.append(canonical_filename(src))
else:
self.source_pkgs.append(src)

@Julian
Copy link

Julian commented Sep 1, 2020

I didn't know this issue existed, though yeah I've fought with this in the past -- FWIW, I count this as yet another reason not to run tox out of cwd.

That's perhaps a less desirable internal (to coverage) solution if it means "tell users of coverage to change their tox.ini", but just to chime in, yeah, that's exactly what I do and recommend.

(So I have changedir = {envtmpdir} in every tox.ini, for this and many other reasons, and then coverage is perfectly happy with source = lines finding the site-packages version of the package).

(EDIT: sample here if you want something runnable: https://github.com/Julian/regret/blob/main/tox.ini#L33-L42 and https://github.com/Julian/regret/blob/main/.coveragerc#L4, and yeah tox -e coverage works fine there.)

graingert added a commit to graingert/coveragepy that referenced this issue Sep 2, 2020
graingert added a commit to graingert/coveragepy that referenced this issue Sep 2, 2020
graingert added a commit to graingert/coveragepy that referenced this issue Sep 2, 2020
graingert added a commit to graingert/coveragepy that referenced this issue Sep 2, 2020
graingert added a commit to graingert/coveragepy that referenced this issue Sep 2, 2020
graingert added a commit to graingert/coveragepy that referenced this issue Sep 2, 2020
graingert added a commit to graingert/coveragepy that referenced this issue Sep 2, 2020
graingert added a commit to graingert/coveragepy that referenced this issue Sep 2, 2020
@nedbat
Copy link
Owner Author

nedbat commented Sep 12, 2020

Fixed in ecd6ab1

@nedbat
Copy link
Owner Author

nedbat commented Sep 13, 2020

This is now released as part of coverage 5.3.

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
3 participants