From 57099034089eb473463979a120644a3aad274870 Mon Sep 17 00:00:00 2001 From: Arun Babu Neelicattu Date: Thu, 21 Mar 2024 12:05:33 +0100 Subject: [PATCH] utils: handle number suffixed old sdist names Resolves: #6996 --- src/poetry/utils/patterns.py | 2 +- tests/utils/test_patterns.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/poetry/utils/patterns.py b/src/poetry/utils/patterns.py index bf88e51b9bf..717a569ddcd 100644 --- a/src/poetry/utils/patterns.py +++ b/src/poetry/utils/patterns.py @@ -14,6 +14,6 @@ ) sdist_file_re = re.compile( - r"^(?P(?P.+?)-(?P\d.*?))" + r"^(?P(?P.+?)-(?P\d[^-]*?))" r"(\.sdist)?\.(?P(zip|tar(\.(gz|bz2|xz|Z))?))$" ) diff --git a/tests/utils/test_patterns.py b/tests/utils/test_patterns.py index 87abb287219..f3df7d52be6 100644 --- a/tests/utils/test_patterns.py +++ b/tests/utils/test_patterns.py @@ -40,3 +40,34 @@ def test_wheel_file_re(filename: str, expected: dict[str, str | None]) -> None: groups = match.groupdict() assert groups == expected + + +@pytest.mark.parametrize( + ["filename", "expected"], + [ + ( + "poetry_core-1.5.0.tar.gz", + { + "namever": "poetry_core-1.5.0", + "name": "poetry_core", + "ver": "1.5.0", + "format": "tar.gz", + }, + ), + ( + "flask-restful-swagger-2-0.35.tar.gz", + { + "namever": "flask-restful-swagger-2-0.35", + "name": "flask-restful-swagger-2", + "ver": "0.35", + "format": "tar.gz", + }, + ), + ], +) +def test_sdist_file_re(filename: str, expected: dict[str, str | None]) -> None: + match = patterns.sdist_file_re.match(filename) + assert match is not None + groups = match.groupdict() + + assert groups == expected