From 42b364ebdbd3fb7e9273fcd968254219167d30f1 Mon Sep 17 00:00:00 2001 From: finswimmer Date: Sat, 7 Nov 2020 15:42:57 +0100 Subject: [PATCH 1/2] fix (utils.patterns): recognize one digit version in filename fix (utils.patterns): version part in filename must be present according PEP491 --- poetry/utils/patterns.py | 9 +++++--- tests/utils/test_patterns.py | 45 ++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 tests/utils/test_patterns.py 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..576a6543ee5 --- /dev/null +++ b/tests/utils/test_patterns.py @@ -0,0 +1,45 @@ +import pytest + +from poetry.utils import patterns + + +@pytest.mark.parametrize( + ["filename", "expected"], + [ + ( + "markdown_captions-2-py3-none-any.whl", + { + "namever": "markdown_captions-2", + "name": "markdown_captions", + "ver": "2", + "build": None, + "pyver": "py3", + "abi": "none", + "plat": "any", + }, + ), + ( + "SQLAlchemy-1.3.20-cp27-cp27mu-manylinux2010_x86_64.whl", + { + "namever": "SQLAlchemy-1.3.20", + "name": "SQLAlchemy", + "ver": "1.3.20", + "build": None, + "pyver": "cp27", + "abi": "cp27mu", + "plat": "manylinux2010_x86_64", + }, + ), + ], +) +def test_wheel_file_re(filename, expected): + match = patterns.wheel_file_re.match(filename) + groups = match.groupdict() + + assert groups["namever"] == expected["namever"] + assert groups["name"] == expected["name"] + assert groups["ver"] == expected["ver"] + assert groups["build"] == expected["build"] + assert groups["pyver"] == expected["pyver"] + assert groups["abi"] == expected["abi"] + assert groups["plat"] == expected["plat"] From 6ac82a7ffc4c8347529ebf9f1bd4f4d2b2881b06 Mon Sep 17 00:00:00 2001 From: David Hilton Date: Tue, 24 Nov 2020 13:19:01 -0500 Subject: [PATCH 2/2] flatten test parameterization as requested in #3338 --- tests/utils/test_patterns.py | 50 +++++++++++++++++------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/tests/utils/test_patterns.py b/tests/utils/test_patterns.py index 576a6543ee5..f5539ae481c 100644 --- a/tests/utils/test_patterns.py +++ b/tests/utils/test_patterns.py @@ -4,42 +4,38 @@ @pytest.mark.parametrize( - ["filename", "expected"], + ["filename", "namever", "name", "ver", "build", "pyver", "abi", "plat"], [ ( "markdown_captions-2-py3-none-any.whl", - { - "namever": "markdown_captions-2", - "name": "markdown_captions", - "ver": "2", - "build": None, - "pyver": "py3", - "abi": "none", - "plat": "any", - }, + "markdown_captions-2", + "markdown_captions", + "2", + None, + "py3", + "none", + "any", ), ( "SQLAlchemy-1.3.20-cp27-cp27mu-manylinux2010_x86_64.whl", - { - "namever": "SQLAlchemy-1.3.20", - "name": "SQLAlchemy", - "ver": "1.3.20", - "build": None, - "pyver": "cp27", - "abi": "cp27mu", - "plat": "manylinux2010_x86_64", - }, + "SQLAlchemy-1.3.20", + "SQLAlchemy", + "1.3.20", + None, + "cp27", + "cp27mu", + "manylinux2010_x86_64", ), ], ) -def test_wheel_file_re(filename, expected): +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"] == expected["namever"] - assert groups["name"] == expected["name"] - assert groups["ver"] == expected["ver"] - assert groups["build"] == expected["build"] - assert groups["pyver"] == expected["pyver"] - assert groups["abi"] == expected["abi"] - assert groups["plat"] == expected["plat"] + 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