Commit 6a0ac4a6 by yamagen0915

Raise a ValueError when author name has invalid

parent 808fd81c
......@@ -163,11 +163,10 @@ class Package(object):
m = AUTHOR_REGEX.match(self._authors[0])
if m is None:
logger.warning(
raise ValueError(
"Invalid author string. Must be in the format: "
"John Smith <john@example.com>"
)
return {"name": None, "email": None}
name = m.group("name")
email = m.group("email")
......@@ -181,11 +180,10 @@ class Package(object):
m = AUTHOR_REGEX.match(self._maintainers[0])
if m is None:
logger.warning(
raise ValueError(
"Invalid maintainer string. Must be in the format: "
"John Smith <john@example.com>"
)
return {"name": None, "email": None}
name = m.group("name")
email = m.group("email")
......
......@@ -17,9 +17,18 @@ def test_package_authors():
assert package.author_name == "John Doe"
assert package.author_email is None
def test_package_authors_invalid():
package = Package("foo", "0.1.0")
package.authors.insert(0, "<John Doe")
assert package.author_name is None
assert package.author_email is None
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"])
......
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