Skip to content

Commit

Permalink
utils: fix canonical package name regex
Browse files Browse the repository at this point in the history
  • Loading branch information
abn authored and kasteph committed Oct 15, 2020
1 parent 0db07bc commit b0d9086
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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"

0 comments on commit b0d9086

Please sign in to comment.