Skip to content

Commit

Permalink
utils: handle number suffixed old sdist names
Browse files Browse the repository at this point in the history
  • Loading branch information
abn committed Mar 21, 2024
1 parent 89e6a63 commit a562bd1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/poetry/utils/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
)

sdist_file_re = re.compile(
r"^(?P<namever>(?P<name>.+?)-(?P<ver>\d.*?))"
r"^(?P<namever>(?P<name>.+?)-(?P<ver>\d[^-]*?))"
r"(\.sdist)?\.(?P<format>(zip|tar(\.(gz|bz2|xz|Z))?))$"
)
31 changes: 31 additions & 0 deletions tests/utils/test_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a562bd1

Please sign in to comment.