示例#1
0
def test_cmp_pkg_version():
    # Test version comparator
    assert_equal(cmp_pkg_version(nib.__version__), 0)
    assert_equal(cmp_pkg_version('0.0'), -1)
    assert_equal(cmp_pkg_version('1000.1000.1'), 1)
    assert_equal(cmp_pkg_version(nib.__version__, nib.__version__), 0)
    for test_ver, pkg_ver, exp_out in (
        ('1.0', '1.0', 0),
        ('1.0.0', '1.0', 0),
        ('1.0', '1.0.0', 0),
        ('1.1', '1.1', 0),
        ('1.2', '1.1', 1),
        ('1.1', '1.2', -1),
        ('1.1.1', '1.1.1', 0),
        ('1.1.2', '1.1.1', 1),
        ('1.1.1', '1.1.2', -1),
        ('1.1', '1.1dev', 1),
        ('1.1dev', '1.1', -1),
        ('1.2.1', '1.2.1rc1', 1),
        ('1.2.1rc1', '1.2.1', -1),
        ('1.2.1rc1', '1.2.1rc', 1),
        ('1.2.1rc', '1.2.1rc1', -1),
        ('1.2.1rc1', '1.2.1rc', 1),
        ('1.2.1rc', '1.2.1rc1', -1),
        ('1.2.1b', '1.2.1a', 1),
        ('1.2.1a', '1.2.1b', -1),
    ):
        assert_equal(cmp_pkg_version(test_ver, pkg_ver), exp_out)
    assert_raises(ValueError, cmp_pkg_version, 'foo.2')
    assert_raises(ValueError, cmp_pkg_version, 'foo.2', '1.0')
    assert_raises(ValueError, cmp_pkg_version, '1.0', 'foo.2')
    assert_raises(ValueError, cmp_pkg_version, '1')
    assert_raises(ValueError, cmp_pkg_version, 'foo')
示例#2
0
def test_fallback_version():
    """Test fallback version is up-to-date

    This should only fail if we fail to bump nibabel.info.VERSION immediately
    after release
    """
    assert (
        # dev version should be larger than tag+commit-githash
        cmp_pkg_version(VERSION) >= 0 or
        # Allow VERSION bump to lag releases by one commit
        VERSION == nib.__version__ + 'dev'), \
        "nibabel.info.VERSION does not match current tag information"
示例#3
0
def test_cmp_pkg_version_0():
    # Test version comparator
    assert cmp_pkg_version(nib.__version__) == 0
    assert cmp_pkg_version('0.0') == -1
    assert cmp_pkg_version('1000.1000.1') == 1
    assert cmp_pkg_version(nib.__version__, nib.__version__) == 0

    # Check dev/RC sequence
    seq = ('3.0.0dev', '3.0.0rc1', '3.0.0rc1.post.dev', '3.0.0rc2',
           '3.0.0rc2.post.dev', '3.0.0')
    for stage1, stage2 in zip(seq[:-1], seq[1:]):
        assert cmp_pkg_version(stage1, stage2) == -1
        assert cmp_pkg_version(stage2, stage1) == 1
示例#4
0
def test_cmp_pkg_version():
    # Test version comparator
    assert_equal(cmp_pkg_version(nib.__version__), 0)
    assert_equal(cmp_pkg_version('0.0'), -1)
    assert_equal(cmp_pkg_version('1000.1000.1'), 1)
    assert_equal(cmp_pkg_version(nib.__version__, nib.__version__), 0)
    for test_ver, pkg_ver, exp_out in (('1.0', '1.0', 0),
                                       ('1.0.0', '1.0', 0),
                                       ('1.0', '1.0.0', 0),
                                       ('1.1', '1.1', 0),
                                       ('1.2', '1.1', 1),
                                       ('1.1', '1.2', -1),
                                       ('1.1.1', '1.1.1', 0),
                                       ('1.1.2', '1.1.1', 1),
                                       ('1.1.1', '1.1.2', -1),
                                       ('1.1', '1.1dev', 1),
                                       ('1.1dev', '1.1', -1),
                                       ('1.2.1', '1.2.1rc1', 1),
                                       ('1.2.1rc1', '1.2.1', -1),
                                       ('1.2.1rc1', '1.2.1rc', 1),
                                       ('1.2.1rc', '1.2.1rc1', -1),
                                       ('1.2.1rc1', '1.2.1rc', 1),
                                       ('1.2.1rc', '1.2.1rc1', -1),
                                       ('1.2.1b', '1.2.1a', 1),
                                       ('1.2.1a', '1.2.1b', -1),
                                       ('1.2.0+1', '1.2', 1),
                                       ('1.2', '1.2.0+1', -1),
                                       ('1.2.1+1', '1.2.1', 1),
                                       ('1.2.1', '1.2.1+1', -1),
                                       ('1.2.1rc1+1', '1.2.1', -1),
                                       ('1.2.1', '1.2.1rc1+1', 1),
                                       ('1.2.1rc1+1', '1.2.1+1', -1),
                                       ('1.2.1+1', '1.2.1rc1+1', 1),
                                      ):
        assert_equal(cmp_pkg_version(test_ver, pkg_ver), exp_out)
    assert_raises(ValueError, cmp_pkg_version, 'foo.2')
    assert_raises(ValueError, cmp_pkg_version, 'foo.2', '1.0')
    assert_raises(ValueError, cmp_pkg_version, '1.0', 'foo.2')
    assert_raises(ValueError, cmp_pkg_version, 'foo')

    # Check dev/RC sequence
    seq = ('3.0.0dev', '3.0.0rc1', '3.0.0rc1.post.dev', '3.0.0rc2', '3.0.0rc2.post.dev', '3.0.0')
    for stage1, stage2 in zip(seq[:-1], seq[1:]):
        assert_equal(cmp_pkg_version(stage1, stage2), -1)
        assert_equal(cmp_pkg_version(stage2, stage1), 1)
示例#5
0
def test_cmp_pkg_version_error(args):
    with pytest.raises(ValueError):
        cmp_pkg_version(*args)
示例#6
0
def test_cmp_pkg_version_1(test_ver, pkg_ver, exp_out):
    # Test version comparator
    assert cmp_pkg_version(test_ver, pkg_ver) == exp_out