Skip to content

Confusing test coverage numbers for conditionals #24181

Closed as not planned
Closed as not planned
@mjbvz

Description

@mjbvz

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

Metadata

Metadata

Assignees

Labels

area-testinginfo-neededIssue requires more information from postertriage-neededNeeds assignment to the proper sub-team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions