Skip to content

Unable to meet precondition and too low coverage, why? #195

Closed Answered by pschanely
LinqLover asked this question in Q&A
Discussion options

You must be logged in to vote

Among too many other things, this fell off my radar. But I've rediscovered it, and finally put a fix (for the failure to cover the function) in v0.0.45:

$ cat discussion195.py 
def compare(version1: str, version2: str):
    v1 = version1.split(".")
    v2 = version2.split(".")
    for i in range(max(len(v1), len(v2))):
        v1i = int(v1[i]) if i < len(v1) else 0
        v2i = int(v2[i]) if i < len(v2) else 0
        if v1i > v2i:
            return 1
        elif v1i < v2i:
            return -1
    return 0

$ crosshair cover discussion195.py --max_uninteresting_iterations=40 --example_output_format=pytest
from discussion195 import compare

def test_compare():
    assert compare('0', …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by LinqLover
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants