-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: widen author name regex and introduce tests (#411)
Support for names such as :Barry-Thomas-Paul: Moss Co-authored-by: Bartosz Sokorski <[email protected]>
- Loading branch information
1 parent
323e277
commit e3ea1b1
Showing
2 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,58 @@ def test_package_authors_invalid() -> None: | |
) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("name", "email"), | ||
[ | ||
("Sébastien Eustace", "[email protected]"), | ||
("John Doe", None), | ||
("'Jane Doe'", None), | ||
('"Jane Doe"', None), | ||
("MyCompany", None), | ||
("Some Company’s", None), | ||
("MyCompany's R&D", "[email protected]"), | ||
("Doe, John", None), | ||
("(Doe, John)", None), | ||
("John Doe", "[email protected]"), | ||
("Doe, John", "[email protected]"), | ||
("MyCompanyName R&D", "[email protected]"), | ||
("John-Paul: Doe", None), | ||
("John-Paul: Doe", "[email protected]"), | ||
("John Doe the 3rd", "[email protected]"), | ||
], | ||
) | ||
def test_package_authors_valid(name: str, email: str | None) -> None: | ||
package = Package("foo", "0.1.0") | ||
|
||
if email is None: | ||
author = name | ||
else: | ||
author = f"{name} <{email}>" | ||
package.authors.insert(0, author) | ||
assert package.author_name == name | ||
assert package.author_email == email | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("name",), | ||
[ | ||
("<[email protected]>",), | ||
("[email protected]",), | ||
("<John Doe",), | ||
("John? Doe",), | ||
("Jane+Doe",), | ||
("~John Doe",), | ||
("John~Doe",), | ||
], | ||
) | ||
def test_package_author_names_invalid(name: str) -> None: | ||
package = Package("foo", "0.1.0") | ||
|
||
package.authors.insert(0, name) | ||
with pytest.raises(ValueError): | ||
package.author_name | ||
|
||
|
||
@pytest.mark.parametrize("groups", [["main"], ["dev"]]) | ||
def test_package_add_dependency_vcs_groups(groups: list[str], f: Factory) -> None: | ||
package = Package("foo", "0.1.0") | ||
|