Skip to content

CI, TST enable branch coverage #40142

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

Merged
merged 1 commit into from
Mar 1, 2021

Conversation

MarcoGorelli
Copy link
Member

@MarcoGorelli MarcoGorelli commented Mar 1, 2021

  • Ensure all linting tests pass, see here for how to run them

As suggested on Gitter - this could help identify more untested parts of the codebase and hence uncover bugs

@jorisvandenbossche
Copy link
Member

What does "branch" coverage exactly mean?

@MarcoGorelli
Copy link
Member Author

MarcoGorelli commented Mar 1, 2021

@jorisvandenbossche here's an example:

# t.py

def main(foo: bool):

    a = 0

    if foo:
        a += 1
    print(a)
# test_t.py

from t import main


def test_main():
    main(True)

Notice how we have never tested the case where foo was False. But, if we run pytest with branch=False, it gives us 100% coverage - indeed, all lines were covered

---------- coverage: platform linux, python 3.7.10-final-0 -----------
Name    Stmts   Miss  Cover   Missing
-------------------------------------
t.py        5      0   100%
-------------------------------------
TOTAL       5      0   100%

However, if we run it with branch=True, then it picks up on the fact that we never went from line 5 directly to line 7 - we always went down the line 5->6->7 route:

---------- coverage: platform linux, python 3.7.10-final-0 -----------
Name    Stmts   Miss Branch BrPart  Cover   Missing
---------------------------------------------------
t.py        5      0      2      1    86%   5->7
---------------------------------------------------
TOTAL       5      0      2      1    86%

Hence, this can help identify untested parts of the codebase

@jorisvandenbossche
Copy link
Member

Ah, thanks for the explanation!

Copy link
Member

@jbrockmendel jbrockmendel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, LGTM

@jreback jreback added the CI Continuous Integration label Mar 1, 2021
@jreback jreback added this to the 1.3 milestone Mar 1, 2021
@jreback jreback merged commit 9da3ca2 into pandas-dev:master Mar 1, 2021
@jreback
Copy link
Contributor

jreback commented Mar 1, 2021

thanks @MarcoGorelli

@MarcoGorelli MarcoGorelli deleted the branch-coverage branch March 1, 2021 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Continuous Integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants