diff --git a/poetry/utils/patterns.py b/poetry/utils/patterns.py index 1d6413c26fe..ec6c53d78d7 100644 --- a/poetry/utils/patterns.py +++ b/poetry/utils/patterns.py @@ -2,8 +2,11 @@ wheel_file_re = re.compile( - r"""^(?P(?P.+?)(-(?P\d.+?))?) - ((-(?P\d.*?))?-(?P.+?)-(?P.+?)-(?P.+?) - \.whl|\.dist-info)$""", + r"^(?P(?P.+?)-(?P\d.*?))" + r"(-(?P\d.*?))?" + r"-(?P.+?)" + r"-(?P.+?)" + r"-(?P.+?)" + r"\.whl|\.dist-info$", re.VERBOSE, ) diff --git a/tests/utils/test_patterns.py b/tests/utils/test_patterns.py new file mode 100644 index 00000000000..f5539ae481c --- /dev/null +++ b/tests/utils/test_patterns.py @@ -0,0 +1,41 @@ +import pytest + +from poetry.utils import patterns + + +@pytest.mark.parametrize( + ["filename", "namever", "name", "ver", "build", "pyver", "abi", "plat"], + [ + ( + "markdown_captions-2-py3-none-any.whl", + "markdown_captions-2", + "markdown_captions", + "2", + None, + "py3", + "none", + "any", + ), + ( + "SQLAlchemy-1.3.20-cp27-cp27mu-manylinux2010_x86_64.whl", + "SQLAlchemy-1.3.20", + "SQLAlchemy", + "1.3.20", + None, + "cp27", + "cp27mu", + "manylinux2010_x86_64", + ), + ], +) +def test_wheel_file_re(filename, namever, name, ver, build, pyver, abi, plat): + match = patterns.wheel_file_re.match(filename) + groups = match.groupdict() + + assert groups["namever"] == namever + assert groups["name"] == name + assert groups["ver"] == ver + assert groups["build"] == build + assert groups["pyver"] == pyver + assert groups["abi"] == abi + assert groups["plat"] == plat