-
Notifications
You must be signed in to change notification settings - Fork 211
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
Removing message formatting rounding #611
Conversation
When defining a coverage threshold (88.45 for example) and the actual coverage is very close (88.449 for example) we will get a failure message. However, the message will be: "FAIL Required test coverage of 88.45% not reached. Total coverage: 88.45%" where it's wrong and confusing since we failed because it's under while it the message it presented as equal. The removing of the rounding will fix it.
Hello @AdiKrasin, can this fix get merged and released? |
@ionelmc Can you have a look at this? Thanks again |
If you are not ok with this change, I'll gladly come up with a PR fixing it as well matching your expectations. This is a long standing issue that is quite painful with long running test suites (because it's a pain to relaunch it to know the coverage) that are distributed (so cannot run with coverage only). I'd argue a more in-line change would be to read the coverage "precision" setting and report it the same way coverage is. Is that something you would be willing to merge and release? |
@@ -341,7 +341,7 @@ def pytest_terminal_summary(self, terminalreporter): | |||
markup = {'red': True, 'bold': True} if failed else {'green': True} | |||
message = ( | |||
'{fail}Required test coverage of {required}% {reached}. ' | |||
'Total coverage: {actual:.2f}%\n' | |||
'Total coverage: {actual}%\n' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would fix the problem you described without changing the output too dramatically.
'Total coverage: {actual}%\n' | |
'Total coverage: {truncate(actual, 2)}%\n' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be cleaner imo to rely on what coverage is doing: https://github.com/nedbat/coveragepy/blob/a1d8d2961c9793cf8d3fa09666012190cdec9214/coverage/results.py#L253
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could just reuse that from coverage? Hopefully @nedbat won't change it soon :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am actively refactoring that file to make more of it public: https://github.com/nedbat/coveragepy/tree/nedbat/public-analysis . We could talk about how to make it useful here.
When defining a coverage threshold (88.45 for example) and the actual coverage is very close (88.449 for example) we will get a failure message. However, the message will be: "FAIL Required test coverage of 88.45% not reached. Total coverage: 88.45%" where it's wrong and confusing since we failed because it's under while it the message it presented as equal. The removing of the rounding will fix it.