Esempio n. 1
0
def test_fromstring():
    assert from_string('1.1') == Version(1, 1)
    assert from_string('1.1 beta 1') == Version(1, 1,
            subrelease=2, subrellevel=1)
    assert from_string('356.42.376 pre-alpha') == Version(356, 42, 376, 0)

    invalid_str = lambda: from_string('foo')
    assert_raises(VersionError, invalid_str)
    try:
        invalid_str()
    except VersionError, e:
        assert str(e) == "Incorrect version string. Please generate it in the manner of 'str(Version(1, 2, 0, ALPHA, 1))'."
Esempio n. 2
0
File: deps.py Progetto: mrts/plugit
def python_version_supported(python_versions):
    # or platform.python_version_tuple()?
    python_version = version.Version(sys.version_info[:3])
    for ver in _parse(python_versions):
        if CMP_OP_MAP[ver['cmp']](python_version,
                version.from_string(ver['ver'])):
            return True
    return False
Esempio n. 3
0
File: deps.py Progetto: mrts/plugit
def is_installed(appname, ver_deps=None, additional_paths=None):
    if additional_paths:
        for path in additional_paths:
            sys.path.insert(0, path)
    try:
        __import__(appname)
        app = sys.modules[appname]
    except ImportError:
        return False

    if not ver_deps:
        return True

    for ver in _parse(ver_deps):
        if CMP_OP_MAP[ver['cmp']](app.VERSION,
                version.from_string(ver['ver'])):
            return True

    raise VersionError("Application %s installed version %s does not "
            "satisfy the version dependencies %s."
            % (appname, str(app.VERSION), str(ver_deps)))
Esempio n. 4
0
    assert v1 > v0
    assert v1 >= v0
    assert v0 < v1
    assert v0 <= v1
    assert v2 > v1
    assert v0 > v3
    assert v4 > v3

    assert v1 != v2
    assert v3 == v5

def test_fromstring():
    assert from_string('1.1') == Version(1, 1)
    assert from_string('1.1 beta 1') == Version(1, 1,
            subrelease=2, subrellevel=1)
    assert from_string('356.42.376 pre-alpha') == Version(356, 42, 376, 0)

    invalid_str = lambda: from_string('foo')
    assert_raises(VersionError, invalid_str)
    try:
        invalid_str()
    except VersionError, e:
        assert str(e) == "Incorrect version string. Please generate it in the manner of 'str(Version(1, 2, 0, ALPHA, 1))'."

    invalid_subrel = lambda: from_string('1.2 bar 1')
    assert_raises(VersionError, invalid_subrel)
    try:
        invalid_subrel()
    except VersionError, e:
        assert str(e) == "Subrelease has to be one of pre-alpha (0), alpha (1), beta (2), prerelease (3)."