Skip to content

Coverage regression for 3.10b4+ (nested if's?) #1188

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

Closed
skirpichev opened this issue Jul 13, 2021 · 5 comments
Closed

Coverage regression for 3.10b4+ (nested if's?) #1188

skirpichev opened this issue Jul 13, 2021 · 5 comments
Labels
bug Something isn't working cpython Reported as a bug in CPython fixed

Comments

@skirpichev
Copy link

skirpichev commented Jul 13, 2021

To Reproduce

For the pr diofant/diofant#1128 try:

$ pip install git+https://github.com/skirpichev/[email protected]
$ cd diofant
$ pip install pytest-cov
$ pytest -q -n0 --cov diofant --cov-report term-missing \
-m 'not slow and not xfail and not regression' diofant/tests/ntheory/test_ntheory.py | \
grep ntheory | grep residue_ntheory.py 
diofant/ntheory/residue_ntheory.py                   565      0    319      2    99%   283->exit, 288->exit

Expected behavior
Mentioned jumps are covered under CPython 3.9.

Additional context

Probably, related coverage failures are in the diofant/functions submodule (should be 100% covered). For instance:

$ pytest -q -n0 --cov diofant --cov-report term-missing \
-m 'not slow and not xfail and not regression' diofant/tests/functions | \
grep functions | grep diofant/functions/exponential.py
diofant/functions/elementary/exponential.py          320     10    194      7    96%   99-102, 334->exit, 342->exit, 376-377, 391-393, 401, 504->exit

Jumps 334->exit, 342->exit and 504->exit should be covered.

PS: I'll try to reduce examples.

@skirpichev skirpichev added the bug Something isn't working label Jul 13, 2021
@nedbat nedbat added the cpython Reported as a bug in CPython label Jul 13, 2021
@nedbat
Copy link
Owner

nedbat commented Jul 13, 2021

Thanks, I've reduced the function down and reported it to CPython as https://bugs.python.org/issue44626.

@nedbat
Copy link
Owner

nedbat commented Jul 13, 2021

I don't know if it's possible to indicate the other failures you are seeing. Some will likely be duplicates of this one, but there might be new scenarios also.

@skirpichev
Copy link
Author

I don't know if it's possible to indicate the other failures you are seeing.

It's easy to reproduce the failure in the exponential.py (see the description). Other failures I've seen in the functions module looks like this one. I suspect the main issue of this report might be same, but I'm not sure.

BTW, to reproduce regressions in the exponential.py you can run just

$ pytest -q -n0 --cov diofant --cov-report term-missing -m 'not slow and not xfail and not regression' \
diofant/tests/functions/test_exponential.py

This should cover all mentioned jumps.

Some will likely be duplicates of this one, but there might be new scenarios also.

Yes, I'll try to examine them as well.

Some strange things happen, that looks like a coveragepy or codecov problems. For instance, I see increase or decrease of the lines hit number (there is no diff wrt the master branch). E.g. here.

@skirpichev
Copy link
Author

UPD: For the second example I got 100% coverage of this "if" block by adding "else: pass" clause after the line 335.

I think, I've found a simplest example:

$ cat test.py 
def f(x):
    x -= 1
    if x:
        if x > 1 and x < 4:
            return False
    else:
        return True


def test_f():
    for x in range(5):
        f(x)
$ pytest --cov test --cov-report term-missing --cov-branch test.py 
============================= test session starts =============================
platform linux -- Python 3.9.2, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /home/sk/bug
plugins: hypothesis-6.14.1, cov-2.12.1, doctestplus-0.9.0, forked-1.3.0, xdist-2.3.0, timeout-1.4.2
collected 1 item                                                                                                                                             

test.py .                                                                 [100%]

----------- coverage: platform linux, python 3.9.2-final-0 -----------
Name      Stmts   Miss Branch BrPart  Cover   Missing
-----------------------------------------------------
test.py       9      0      6      0   100%
-----------------------------------------------------
TOTAL         9      0      6      0   100%


============================= 1 passed in 0.16s ===============================

$ pytest --cov test --cov-report term-missing --cov-branch test.py 
========================== test session starts ===========================
platform linux -- Python 3.10.0b4+, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /home/sk/bug
plugins: cov-2.12.1, forked-1.3.0, xdist-2.3.0, timeout-1.4.2, hypothesis-6.14.2
collected 1 item                                                                                                                                             

test.py .                                                                       [100%]

----------- coverage: platform linux, python 3.10.0-beta-4 -----------
Name      Stmts   Miss Branch BrPart  Cover   Missing
-----------------------------------------------------
test.py       9      0      6      1    93%   4->exit
-----------------------------------------------------
TOTAL         9      0      6      1    93%

========================= 1 passed in 0.58s =====================

Again, "else: pass" after line 5 does "fix" this regression.

@skirpichev
Copy link
Author

Both problems seems to be resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cpython Reported as a bug in CPython fixed
Projects
None yet
Development

No branches or pull requests

2 participants