def generate_version(version: str): """ Generates a new version using semver Parameters: version (str): version to parse Returns: string: new version number """ try: parsed_version = semver.parse_version_info(version) new_version = parsed_version.bump_patch() updated_version = semver.replace(version, patch=new_version.patch) return updated_version except Exception as err: return err
def test_replace_raises_TypeError_for_invalid_keyword_arg(): with pytest.raises(TypeError, match=r"replace\(\).*unknown.*"): assert replace("1.2.3", unknown="should_raise")
def test_replace_method_replaces_requested_parts(version, parts, expected): assert replace(version, **parts) == expected