Beispiel #1
0
def test_it(loose, strict):
    import pytest
    from semver import make_semver, eq

    with pytest.raises(ValueError):
        make_semver(loose, False)

    lv = make_semver(loose, True)
    assert lv.version == strict
    assert eq(loose, strict, True) is True

    with pytest.raises(ValueError):
        eq(loose, strict, False)

    with pytest.raises(ValueError):
        make_semver(strict, False).compare(loose)
Beispiel #2
0
def comparison():
  # [version1, version2]
  # version1 should be greater than version2
  tests = [['0.0.0', '0.0.0-foo'],
    ['0.0.1', '0.0.0'],
    ['1.0.0', '0.9.9'],
    ['0.10.0', '0.9.0'],
    ['0.99.0', '0.10.0'],
    ['2.0.0', '1.2.3'],
    ['v0.0.0', '0.0.0-foo'],
    ['v0.0.1', '0.0.0'],
    ['v1.0.0', '0.9.9'],
    ['v0.10.0', '0.9.0'],
    ['v0.99.0', '0.10.0'],
    ['v2.0.0', '1.2.3'],
    ['0.0.0', 'v0.0.0-foo'],
    ['0.0.1', 'v0.0.0'],
    ['1.0.0', 'v0.9.9'],
    ['0.10.0', 'v0.9.0'],
    ['0.99.0', 'v0.10.0'],
    ['2.0.0', 'v1.2.3'],
    ['1.2.3', '1.2.3-asdf'],
    ['1.2.3', '1.2.3-4'],
    ['1.2.3', '1.2.3-4-foo'],
    ['1.2.3-5-foo', '1.2.3-5'],
    ['1.2.3-5', '1.2.3-4'],
    ['1.2.3-5-foo', '1.2.3-5-Foo'],
    ['3.0.0', '2.7.2+asdf'],
    ['1.2.3-a.10', '1.2.3-a.5'],
    ['1.2.3-a.b', '1.2.3-a.5'],
    ['1.2.3-a.b', '1.2.3-a'],
    ['1.2.3-a.b.c.10.d.5', '1.2.3-a.b.c.5.d.100']
  ]

  for v in tests:
    v0 = v[0]
    v1 = v[1]
    ok(gt(v0, v1), "gt('" + v0 + "', '" + v1 + "')")
    ok(lt(v1, v0), "lt('" + v1 + "', '" + v0 + "')")
    ok(not gt(v1, v0), "!gt('" + v1 + "', '" + v0 + "')")
    ok(not lt(v0, v1), "!lt('" + v0 + "', '" + v1 + "')")
    ok(eq(v0, v0), "eq('" + v0 + "', '" + v0 + "')")
    ok(eq(v1, v1), "eq('" + v1 + "', '" + v1 + "')")
    ok(ne(v0, v1), "ne('" + v0 + "', '" + v1 + "')")
Beispiel #3
0
def equality():
  # [version1, version2]
  # version1 should be equivalent to version2
  tests = [['1.2.3', 'v1.2.3'],
    ['1.2.3', '=1.2.3'],
    ['1.2.3', 'v 1.2.3'],
    ['1.2.3', '= 1.2.3'],
    ['1.2.3', ' v1.2.3'],
    ['1.2.3', ' =1.2.3'],
    ['1.2.3', ' v 1.2.3'],
    ['1.2.3', ' = 1.2.3'],
    ['1.2.3-0', 'v1.2.3-0'],
    ['1.2.3-0', '=1.2.3-0'],
    ['1.2.3-0', 'v 1.2.3-0'],
    ['1.2.3-0', '= 1.2.3-0'],
    ['1.2.3-0', ' v1.2.3-0'],
    ['1.2.3-0', ' =1.2.3-0'],
    ['1.2.3-0', ' v 1.2.3-0'],
    ['1.2.3-0', ' = 1.2.3-0'],
    ['1.2.3-1', 'v1.2.3-1'],
    ['1.2.3-1', '=1.2.3-1'],
    ['1.2.3-1', 'v 1.2.3-1'],
    ['1.2.3-1', '= 1.2.3-1'],
    ['1.2.3-1', ' v1.2.3-1'],
    ['1.2.3-1', ' =1.2.3-1'],
    ['1.2.3-1', ' v 1.2.3-1'],
    ['1.2.3-1', ' = 1.2.3-1'],
    ['1.2.3-beta', 'v1.2.3-beta'],
    ['1.2.3-beta', '=1.2.3-beta'],
    ['1.2.3-beta', 'v 1.2.3-beta'],
    ['1.2.3-beta', '= 1.2.3-beta'],
    ['1.2.3-beta', ' v1.2.3-beta'],
    ['1.2.3-beta', ' =1.2.3-beta'],
    ['1.2.3-beta', ' v 1.2.3-beta'],
    ['1.2.3-beta', ' = 1.2.3-beta'],
    ['1.2.3-beta+build', ' = 1.2.3-beta+otherbuild'],
    ['1.2.3+build', ' = 1.2.3+otherbuild'],
    ['1.2.3-beta+build', '1.2.3-beta+otherbuild'],
    ['1.2.3+build', '1.2.3+otherbuild'],
    ['  v1.2.3+build', '1.2.3+otherbuild']
  ]

  for v in tests:
    v0 = v[0]
    v1 = v[1]
    ok(eq(v0, v1), "eq('" + v0 + "', '" + v1 + "')")
    ok(not ne(v0, v1), "!ne('" + v0 + "', '" + v1 + "')")
    ok(not gt(v0, v1), "!gt('" + v0 + "', '" + v1 + "')")
    ok(ge(v0, v1), "ge('" + v0 + "', '" + v1 + "')")
    ok(not lt(v0, v1), "!lt('" + v0 + "', '" + v1 + "')")
    ok(le(v0, v1), "le('" + v0 + "', '" + v1 + "')")
Beispiel #4
0
def test_eq(v0, v1, loose):
    from semver import eq
    assert eq(v0, v1, loose) is True
def test_eq(v0, v1, loose):
    from semver import eq
    assert eq(v0, v1, loose) is True