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 environment in Tox does not measure coverage accurately #80

Open
Daverball opened this issue May 22, 2023 · 3 comments
Open

Coverage environment in Tox does not measure coverage accurately #80

Daverball opened this issue May 22, 2023 · 3 comments

Comments

@Daverball
Copy link
Contributor

Daverball commented May 22, 2023

The environment for coverage currently only is run on a specific Python/SQLAlchemy version and without the two Postgres specific test-runs on the CI, as such it does not accurately represent the coverage.

I have found that the best way to do coverage reports with tox and multiple environments is to set the environment variable that changes the name of the .coverage file, so each environment calculates the coverage and creates a unique file. Then at the end you run your report environment to stitch them together.

On the CI you would either have to create Artifacts and use them in a final dependent runner that stitches them together, or possibly coveralls supports stitching them together for you, if you upload multiple coverage reports from the same commit. (I know Codecov supports uploading multiple reports and stitches them together for you, but I have never used coveralls)

@Daverball
Copy link
Contributor Author

Daverball commented May 22, 2023

Note that as part of #79 we possibly temporarily dropped the required coverage percentage or omitted the test code from test coverage, so this should once again be raised/re-enabled once this is fixed.

@Daverball
Copy link
Contributor Author

Daverball commented May 22, 2023

Here is an example tox.ini from pytest-codecov: https://github.com/seantis/pytest-codecov/blob/master/tox.ini

Basically you are always measuring coverage for every test environment in a coverage file specific to that environment and all the report environment does is take the existing coverage files and combining them. pytest-cov makes this a little less cumbersome, but you could certainly accomplish the same results without it.

In the CI case with the additional testruns for postgres you would have to create two additional coverage files per environment. (Or four if you look at all permutations, but only ever two of them will be active in the same environment)

@icemac
Copy link
Member

icemac commented May 23, 2023

Coveralls also supports multiple uploads and combines them. To get a real coverage number only each action run needs to report to coveralls.
This way it is not possible to get local coverage to a nice value but that is okay as locally we mostly do not run against an actual PostgreSQL installation but only the SQLite tests.

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

No branches or pull requests

2 participants