Esempio n. 1
0
def test_fail_base_version_constructor(major_number, minor_number,
                                       patch_number, ExpectedErrorType):
    with pytest.raises(ExpectedErrorType):
        BaseVersion(
            major_number=major_number,
            minor_number=minor_number,
            patch_number=patch_number,
        )
Esempio n. 2
0
def test_base_version_constructor_and_str(major_number, minor_number,
                                          patch_number,
                                          expected_output_string):
    assert str(
        BaseVersion(
            major_number=major_number,
            minor_number=minor_number,
            patch_number=patch_number,
        )) == expected_output_string
Esempio n. 3
0
def test_base_version_implements_remaining_comparision_operators():
    assert BaseVersion.parse('32.0') <= BaseVersion.parse('32.0')
    assert BaseVersion.parse('32.0') <= BaseVersion.parse('33.0')

    assert BaseVersion.parse('33.0') >= BaseVersion.parse('32.0')
    assert BaseVersion.parse('33.0') >= BaseVersion.parse('33.0')

    assert BaseVersion.parse('33.0') > BaseVersion.parse('32.0')
    assert not BaseVersion.parse('33.0') > BaseVersion.parse('33.0')

    assert not BaseVersion.parse('32.0') < BaseVersion.parse('32.0')

    assert BaseVersion.parse('33.0') != BaseVersion.parse('32.0')
Esempio n. 4
0
def test_base_version_raises_eq_operator(wrong_type):
    with pytest.raises(ValueError):
        assert BaseVersion.parse('32.0') == wrong_type
    # AttributeError is raised by LooseVersion and StrictVersion
    with pytest.raises((ValueError, AttributeError)):
        assert wrong_type == BaseVersion.parse('32.0')
Esempio n. 5
0
def test_base_version_implements_eq_operator(equivalent_version_string):
    assert BaseVersion.parse('32.0') == BaseVersion.parse(
        equivalent_version_string)
    # raw strings are also converted
    assert BaseVersion.parse('32.0') == equivalent_version_string
Esempio n. 6
0
def test_base_version_implements_lt_operator(previous, next):
    assert BaseVersion.parse(previous) < BaseVersion.parse(next)
Esempio n. 7
0
def test_base_version_raises_when_invalid_version_is_given(
        version_string, ExpectedErrorType):
    with pytest.raises(ExpectedErrorType):
        BaseVersion.parse(version_string)
Esempio n. 8
0
def test_base_version_constructor_minimum_kwargs():
    assert str(BaseVersion(32, 0)) == '32.0'
    assert str(BaseVersion(32, 0, 1)) == '32.0.1'
    assert str(BaseVersion(32, 1, 0)) == '32.1.0'
Esempio n. 9
0
def test_base_version_bump_raises():
    version = BaseVersion.parse('32.0')
    with pytest.raises(ValueError):
        version.bump('non_existing_number')
Esempio n. 10
0
def test_base_version_bump(version_string, field, expected):
    version = BaseVersion.parse(version_string)
    assert str(version.bump(field)) == expected
Esempio n. 11
0
def test_base_version_hashable():
    hash(BaseVersion.parse('63.0'))
Esempio n. 12
0

def test_base_version_hashable():
    hash(BaseVersion.parse('63.0'))


class _DummyVersion():
    def __init__(self, major_number):
        self.major_number = major_number


@pytest.mark.parametrize(
    'base_version, other, field, expected',
    (
        (
            BaseVersion(32, 0),
            BaseVersion(32, 0),
            'major_number',
            0,
        ),
        (
            BaseVersion(32, 0),
            BaseVersion(33, 0),
            'major_number',
            -1,
        ),
        (
            BaseVersion(32, 0),
            BaseVersion(31, 0),
            'major_number',
            1,