Use Project-URL metadata field to get a PyPI package's homepage URL (#33089)

Resolves #33085.
This commit is contained in:
Kemal Zebari 2025-01-03 13:09:47 -08:00 committed by GitHub
parent 68972a9947
commit 188e0ee8e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 116 additions and 10 deletions

View file

@ -36,3 +36,13 @@ func TestIsValidNameAndVersion(t *testing.T) {
assert.False(t, isValidNameAndVersion("test-name", "1.0.1aa"))
assert.False(t, isValidNameAndVersion("test-name", "1.0.0-alpha.beta"))
}
func TestNormalizeLabel(t *testing.T) {
// Cases fetched from https://packaging.python.org/en/latest/specifications/well-known-project-urls/#label-normalization.
assert.Equal(t, "homepage", normalizeLabel("Homepage"))
assert.Equal(t, "homepage", normalizeLabel("Home-page"))
assert.Equal(t, "homepage", normalizeLabel("Home page"))
assert.Equal(t, "changelog", normalizeLabel("Change_Log"))
assert.Equal(t, "whatsnew", normalizeLabel("What's New?"))
assert.Equal(t, "github", normalizeLabel("github"))
}