You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a complicated situation. In theory, the condition on line 7 could be False and the if could return from the function. We can tell by looking at the code and thinking about it that if that condition is False it won't return from the function, it will branch to the except ZeroDivisionError on line 9. But coverage.py can't do that level of analysis, so it decides there is a possibility that has been missed. The message is a bit misleading, the missing branch isn't "because the condition on line 7 was never false", it's more complicated than that. (BTW: that message in the latest code has been flipped to "because the condition on line 7 was always true".)
You should had a partial branch pragma to the condition to quiet the message.
We can tell by looking at the code and thinking about it that if that condition is False it won't return from the function, it will branch to the except ZeroDivisionError on line 9. But coverage.py can't do that level of analysis, so it decides there is a possibility that has been missed.
It seems difficult to check such code correctly...
I know this code is bad, but I cannot refactor it right now.
So I wanted to know how to properly check it with coverage...
Summary
The target function is below.(This is code that occurs the issue.)
The test function is below.
Expected vs actual result
line 7 didn't return from function 'main', because the condition on line 7 was never false
line 7 didn't return from function 'main', because the condition on line 7 was always true
(5.0.0)Reproducer
Versions
Config
not use.
What has been tried to solve the problem
Add dummy code to line 9.
The text was updated successfully, but these errors were encountered: