Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
6a0ac4a6
Commit
6a0ac4a6
authored
Jun 26, 2020
by
yamagen0915
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Raise a ValueError when author name has invalid
parent
808fd81c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
6 deletions
+13
-6
poetry/packages/package.py
+2
-4
tests/packages/test_package.py
+11
-2
No files found.
poetry/packages/package.py
View file @
6a0ac4a6
...
...
@@ -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"
)
...
...
tests/packages/test_package.py
View file @
6a0ac4a6
...
...
@@ -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"
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment