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

coverage 5.6b1 breaks support for testing code when installed #1143

Closed
FFY00 opened this issue Apr 14, 2021 · 5 comments
Closed

coverage 5.6b1 breaks support for testing code when installed #1143

FFY00 opened this issue Apr 14, 2021 · 5 comments
Labels
bug Something isn't working fixed

Comments

@FFY00
Copy link

FFY00 commented Apr 14, 2021

Describe the bug
There are some cases where I want to test if my code works when installed. For this reason, I install the code and run the test suite. This has been working fine so far, but the latest beta breaks our setup.

cc @gaborbernat

To Reproduce

  1. What version of Python are you using? 2.7, >=3.5
  2. What version of coverage.py are you using? 5.6b1
  3. What versions of what packages do you have installed?
apipkg==1.5,attrs==20.3.0,build @ file:///home/anubis/git/python-build/.tox/.tmp/package/1/build-0.3.1.post1.tar.gz,coverage==5.6b1,execnet==1.8.0,filelock==3.0.12,iniconfig==1.1.1,packaging==20.9,pep517==0.10.0,pluggy==0.13.1,py==1.10.0,pyparsing==2.4.7,pytest==6.2.3,pytest-cov==2.11.1,pytest-forked==1.3.0,pytest-mock==3.5.1,pytest-xdist==2.2.1,toml==0.10.2
  1. What code are you running? https://github.com/pypa/build, latest commit (bb8878c5fe0b13f6b1ef416dfd93c536ed01e625)
  2. What commands did you run? tox -e py39 -e coverage

Patch to pin coverage:

diff --git a/setup.cfg b/setup.cfg
index f3831d6..9106151 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -53,6 +53,7 @@ test =
     filelock>=3
     pytest>=4
     pytest-cov>=2
+    coverage==5.6b1
     pytest-mock>=2
     pytest-xdist>=1.34
 typing =

Expected behavior
As explained above, I would like to be able to track the coverage of my code when I run the test suite with it installed.

@FFY00 FFY00 added the bug Something isn't working label Apr 14, 2021
@nedbat
Copy link
Owner

nedbat commented Apr 15, 2021

Thanks for the reproduction.

With coverage 5.5, this is measuring all of the code installed your virtualenv. Then in the reporting phase, you've used [paths] to map back to src, and -i to skip any file that doesn't exist. This results in reporting on just the src and tests directory, like you want.

With coverage 5.6b1, you will get the same results with [coverage.run] source = build, tests, and you can remove the -i switches. This will measure only the files you want.

I hope you'll agree that this is a better use of coverage.py. This was a good example of the kind of upgrading that people will need to do.

@FFY00
Copy link
Author

FFY00 commented Apr 15, 2021

Yes, this is a much better configuration IMO! Thanks 😊

@gaborbernat
Copy link
Contributor

gaborbernat commented Apr 15, 2021

@nedbat in our case this works because we use a source layout. How would one measure coverage on installed files if they are not using the src layout?

Also note, while the suggested fix works, this makes 5.6b1 a breaking change for any CI doing any level of strictness check (which I'd hope are a lot). So perhaps this kind of major change should roll out as 6.0 instead.

@nedbat
Copy link
Owner

nedbat commented Apr 15, 2021

@gaborbernat you are probably right about the 6.0 version number.

If you weren't using the src layout, source_pkgs=build would work for you (and would also work for the src layout).

@nedbat nedbat added this to the 6.0 milestone Jul 25, 2021
@nedbat
Copy link
Owner

nedbat commented Oct 14, 2021

I think this can be closed now... Please re-open if I am wrong.

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