def check_version_different_order(v1, v2):
    """Check order of versions, the first version must be greater that the second."""
    c = ComparableVersion(v1)
    c1 = ComparableVersion(v2)

    # check using `compare_to` method
    res = c.compare_to(c1)
    assert res is not None
    assert res == 1, "{} is less than {}".format(v1, v2)

    # check using `compare_to` method and version string
    res = c.compare_to(v2)
    assert res is not None
    assert res == 1, "{} is less than {}".format(v1, v2)

    # check using rich comparison
    assert c > c1, "rich comparison: {} is not greater than {}".format(v1, v2)
def check_version_equal(v1, v2):
    """Check if versions are equal."""
    c = ComparableVersion(v1)
    c1 = ComparableVersion(v2)

    # check using `compare_to` method
    res = c.compare_to(c1)
    assert res is not None
    assert res == 0, "{} is not equal to {}".format(v1, v2)

    # check using `compare_to` method and version string
    res = c.compare_to(v2)
    assert res is not None
    assert res == 0, "{} is not equal to {}".format(v1, v2)

    # check using rich comparison
    assert c == c1, "rich comparison: {} is not equal to {}".format(v1, v2)
def check_version_order(v1, v2):
    """Check order of versions."""
    c = ComparableVersion(v1)
    c1 = ComparableVersion(v2)

    # check using `compare_to` method
    res = c.compare_to(c1)
    assert res is not None
    assert res == -1, "{} is greater than {}".format(v1, v2)

    # check using `compare_to` method and version string
    res = c.compare_to(v2)
    assert res is not None
    assert res == -1, "{} is greater than {}".format(v1, v2)

    # check using rich comparison
    assert c < c1, "rich comparison: {} is not lower than {}".format(v1, v2)
def test_comparisons_wrong_type():
    """Test function compare_to."""
    v1 = "1.0.0"
    c = ComparableVersion(v1)

    # check the TypeError
    with pytest.raises(TypeError):
        c.compare_to(None)
        c.compare_to(True)
        c.compare_to(False)
        c.compare_to([])
        c.compare_to({})
        c.compare_to(42)
        c.compare_to(3.14)
        c.compare_to(1 + 2j)
def check_version_equal(v1, v2):
    """Check if versions are equal."""
    c = ComparableVersion(v1)
    c1 = ComparableVersion(v2)
    res = c.compare_to(c1)
    assert res == 0, "{} is not equal to  {}".format(v1, v2)
def check_version_different_order(v1, v2):
    """Check order of versions, the first version must be greater that the second."""
    c = ComparableVersion(v1)
    c1 = ComparableVersion(v2)
    res = c.compare_to(c1)
    assert res == 1, "{} is less than {}".format(v1, v2)
def check_version_order(v1, v2):
    """Check order of versions."""
    c = ComparableVersion(v1)
    c1 = ComparableVersion(v2)
    res = c.compare_to(c1)
    assert res == -1, "{} is greater than {}".format(v1, v2)