Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils: fix canonical package name regex #100

Merged
merged 1 commit into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion poetry/core/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from collections import Mapping


_canonicalize_regex = re.compile("[-_]+")
_canonicalize_regex = re.compile(r"[-_.]+")


def canonicalize_name(name): # type: (str) -> str
Expand Down
10 changes: 10 additions & 0 deletions tests/utils/test_helpers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import pytest

from poetry.core.utils.helpers import canonicalize_name
from poetry.core.utils.helpers import parse_requires


Expand Down Expand Up @@ -52,3 +55,10 @@ def test_parse_requires():
'isort@ git+git://github.com/timothycrosley/isort.git@e63ae06ec7d70b06df9e528357650281a3d3ec22#egg=isort ; extra == "dev"',
]
assert result == expected


@pytest.mark.parametrize(
"raw", ["a-b-c", "a.b-c", "a.b.c", "a_b-c", "a_b_c", "a-b_c", "a.b_c", "a-b.c"]
)
def test_utils_helpers_canonical_names(raw):
assert canonicalize_name(raw) == "a-b-c"