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, )
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
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')
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')
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
def test_base_version_implements_lt_operator(previous, next): assert BaseVersion.parse(previous) < BaseVersion.parse(next)
def test_base_version_raises_when_invalid_version_is_given( version_string, ExpectedErrorType): with pytest.raises(ExpectedErrorType): BaseVersion.parse(version_string)
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'
def test_base_version_bump_raises(): version = BaseVersion.parse('32.0') with pytest.raises(ValueError): version.bump('non_existing_number')
def test_base_version_bump(version_string, field, expected): version = BaseVersion.parse(version_string) assert str(version.bump(field)) == expected
def test_base_version_hashable(): hash(BaseVersion.parse('63.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,