def test_it(v, loose, exc):
    import pytest
    from semver import make_semver
    if exc is not None:
        with pytest.raises(exc):
            make_semver(v, loose)
    else:
        make_semver(v, loose)
Esempio n. 2
0
def version_list_generator(cursor):
    for (version, ) in cursor:
        try:
            semver.make_semver(version, loose=False)
            yield version
        except Exception as exc:
            print('Skipping {}: {}'.format(version, exc))
            continue
Esempio n. 3
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)
Esempio n. 4
0
def partition(versions, loose=False):
    oks, ngs = [], []
    for v in versions:
        try:
            oks.append(make_semver(v, loose=loose))
        except ValueError as e:
            ngs.append((v, e))
    return oks, ngs
Esempio n. 5
0
def test_parse(v, loose, expected):
    from semver import make_semver
    got = make_semver(v, loose=loose)
    assert got.raw == v
    assert got.major == expected["major"]
    assert got.minor == expected["minor"]
    assert got.patch == expected["patch"]
    assert got.prerelease == expected["prerelease"]
    assert got.build == expected["build"]
    assert got.micro_versions == expected["micro_versions"]
Esempio n. 6
0
def custom_max_satisfying(candidates, query):
    if not query.startswith("~"):
        return max_satisfying(candidates, query, loose=True)
    else:
        normalized = defaultdict(list)
        for x in candidates:
            v = make_semver(x, loose=True)
            normalized["{}.{}.{}".format(v.major, v.minor, v.patch)].append(v)
        mv = max_satisfying(list(normalized), query)
        return sort(normalized[mv], loose=True)[-1].version
Esempio n. 7
0
def custom_max_satisfying(candidates, query):
    if not query.startswith("~"):
        return max_satisfying(candidates, query, loose=True)
    else:
        normalized = defaultdict(list)
        for x in candidates:
            v = make_semver(x, loose=True)
            normalized["{}.{}.{}".format(v.major, v.minor, v.patch)].append(v)
        mv = max_satisfying(list(normalized), query)
        return sort(normalized[mv], loose=True)[-1].version
Esempio n. 8
0
def test_parse(v, loose, expected):
    from semver import make_semver
    got = make_semver(v, loose=loose)
    assert got.raw == v
    assert got.major == expected["major"]
    assert got.minor == expected["minor"]
    assert got.patch == expected["patch"]
    assert got.prerelease == expected["prerelease"]
    assert got.build == expected["build"]
    assert got.micro_versions == expected["micro_versions"]
def test_it(v):
    import pytest
    from semver import make_semver
    with pytest.raises(ValueError):
        loose = False
        make_semver(v, loose)
Esempio n. 10
0
from semver import make_semver
print(make_semver("4.1.3.2+jenkins", loose=True).__dict__)
Esempio n. 11
0
def _sorted(versions, loose=False, key=None):
    key = key or cmp_to_key(lambda x, y: x.compare(y))
    return sorted([make_semver(v, loose=loose) for v in versions], key=key)
Esempio n. 12
0
import logging
from semver import make_semver, max_satisfying
# logging.basicConfig(level=logging.DEBUG)

print(make_semver('4.1.3.0', loose=True))
print(
    max_satisfying(['3.1.1', '4.1.1.0', '4.1.2.0', '4.1.3.0'],
                   '>= 4.1.0 <5.0.0',
                   loose=True))
print(
    max_satisfying(['3.1.1', '4.1.2.0', '4.1.1.0', '4.1.3.0'],
                   '^4.1',
                   loose=True))
Esempio n. 13
0
import logging
from semver import make_semver, max_satisfying
# logging.basicConfig(level=logging.DEBUG)

print(make_semver('4.1.3.0', loose=True))
print(max_satisfying(['3.1.1', '4.1.1.0', '4.1.2.0', '4.1.3.0'], '>= 4.1.0 <5.0.0', loose=True))
print(max_satisfying(['3.1.1', '4.1.2.0', '4.1.1.0', '4.1.3.0'], '^4.1', loose=True))
Esempio n. 14
0
from semver import make_semver
print(make_semver("1.2.3.4", loose=True))
def test_it(v):
    import pytest
    from semver import make_semver
    with pytest.raises(ValueError):
        loose = False
        make_semver(v, loose)