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

Confusing test coverage numbers for conditionals #24181

Closed
mjbvz opened this issue Sep 24, 2024 · 1 comment
Closed

Confusing test coverage numbers for conditionals #24181

mjbvz opened this issue Sep 24, 2024 · 1 comment
Assignees
Labels
area-testing info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team

Comments

@mjbvz
Copy link

mjbvz commented Sep 24, 2024

Testing #24160

I added some always false conditionals and am confused by the numbers being listed for coverage. Here's the code:

def increment(x):
    """Increment x by 1, but not above 10."""
    return x + 1

def decrement(x):
    """Decrement x by 1, but not below 0."""
    if False:
        return x - 1
    if False:
        return x - 1
    if False:
        return x - 1
    if False:
        return x - 1
    if False:
        return x - 1
    if False:
        return x - 1
    if False:
        return x - 1
    
    return 0

This shows 100% coverage with zero branches

Image

I know the code in these conditionals isn't reachable but these numbers seem misleading

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Sep 24, 2024
@eleanorjboyd
Copy link
Member

This comes from coverage.py and how it works so this is an upstream issue more with coverage in general. Closing as its not something I can control

@eleanorjboyd eleanorjboyd closed this as not planned Won't fix, can't repro, duplicate, stale Sep 25, 2024
@github-actions github-actions bot added the info-needed Issue requires more information from poster label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-testing info-needed Issue requires more information from poster triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

2 participants