Commit 413c07e0 by finswimmer Committed by GitHub

Merge pull request #1935 from yamagen0915/fix_getting_author_name

Add error handling for malfoemed author
parents cd6da2c0 6a0ac4a6
......@@ -163,6 +163,12 @@ class Package(object):
m = AUTHOR_REGEX.match(normalize("NFC", self._authors[0]))
if m is None:
raise ValueError(
"Invalid author string. Must be in the format: "
"John Smith <john@example.com>"
)
name = m.group("name")
email = m.group("email")
......@@ -174,6 +180,12 @@ class Package(object):
m = AUTHOR_REGEX.match(normalize("NFC", self._maintainers[0]))
if m is None:
raise ValueError(
"Invalid maintainer string. Must be in the format: "
"John Smith <john@example.com>"
)
name = m.group("name")
email = m.group("email")
......
......@@ -30,6 +30,19 @@ def test_package_authors():
assert package.author_email is None
def test_package_authors_invalid():
package = Package("foo", "0.1.0")
package.authors.insert(0, "<John Doe")
with pytest.raises(ValueError) as e:
package.author_name
assert (
str(e.value)
== "Invalid author string. Must be in the format: John Smith <john@example.com>"
)
@pytest.mark.parametrize("category", ["main", "dev"])
def test_package_add_dependency_vcs_category(category):
package = Package("foo", "0.1.0")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment