def test_parse( version, expected_major, expected_minor, expected_patch, expected_prerelease, expected_build_metadata, ): semver = parse_semver(version) assert expected_major == semver.major assert expected_minor == semver.minor assert expected_patch == semver.patch assert expected_prerelease == semver.pre_release assert expected_build_metadata == semver.build_metadata assert version == str(semver)
def test_parse_invalid(): with pytest.raises(ValueError): parse_semver("blerg")
def test_transform_non_changing_non_numerical_part(self, part): version = parse_semver(self._raw_version) value = getattr(version, part) with pytest.raises(ValueError): self._transform(part, version, value)
def test_transform_non_increasing_numerical_part(self, value): with pytest.raises(ValueError): self._transform("major", parse_semver("2.0.0"), value)
def test_transform_invalid_value_for_numerical_part(self): with pytest.raises(ValueError): self._transform("major", parse_semver("2.0.0"), "a")
def test_transform_invalid_part(self): with pytest.raises(ValueError): self._transform("dummy", parse_semver("2.0.0"), 1)
def test_transform(self, part, value, expected_version): new_semver = self._transform(part, parse_semver(self._raw_version), value) assert expected_version == str(new_semver)
def test_transform_invalid_parts(self, part): with pytest.raises(ValueError): self._transform(part, parse_semver(self._raw_version))