def test_versionvariants_parses_correct_version_string(self): assert versions.VersionVariants("5.0.3").all_versions == [("5.0.3", "with_patch"), ("5.0", "with_minor"), ("5", "with_major")] assert versions.VersionVariants("7.12.1-SNAPSHOT").all_versions == [ ("7.12.1-SNAPSHOT", "with_suffix"), ("7.12.1", "with_patch"), ("7.12", "with_minor"), ("7", "with_major"), ] assert versions.VersionVariants("10.3.63").all_versions == [("10.3.63", "with_patch"), ("10.3", "with_minor"), ("10", "with_major")]
def test_latest_bounded_minor(self, seed): _alternatives = ["7", "7.10", "7.11.2", "7.2", "5", "6", "master"] random.seed(seed) alternatives = _alternatives.copy() random.shuffle(alternatives) assert versions.latest_bounded_minor( alternatives, versions.VersionVariants("7.6.3")) == 2 assert versions.latest_bounded_minor(alternatives, versions.VersionVariants("7.12.3")) == 10,\ "Nearest alternative with major.minor, skip alternatives with major.minor.patch" assert versions.latest_bounded_minor(alternatives, versions.VersionVariants("7.11.2")) == 10,\ "Skips all alternatives with major.minor.patch, even if exact match" assert versions.latest_bounded_minor(alternatives, versions.VersionVariants("7.1.0")) is None,\ "No matching alternative with minor version"
def test_versions_rejects_invalid_version_strings(self): with pytest.raises( exceptions.InvalidSyntax, match=re.escape( r"version string '5.0.0a-SNAPSHOT' does not conform to pattern " r"'^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$'")): versions.VersionVariants("5.0.0a-SNAPSHOT")