Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions hashin.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,9 @@ def expand_python_version(version):
Expand Python versions to all identifiers used on PyPI.

>>> expand_python_version('3.5')
['3.5', 'py3', 'py2.py3', 'cp35']
['3.5', 'cp35', 'py2.py3', 'py3', 'py3.5', 'py35', 'source']
"""
if not re.match(r"^\d\.\d$", version):
if not re.match(r"^\d\.\d{1,2}$", version):
return [version]

major, minor = version.split(".")
Expand Down
20 changes: 20 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2189,6 +2189,26 @@ def test_expand_python_version():
"source",
]

assert sorted(hashin.expand_python_version("3.10")) == [
"3.10",
"cp310",
"py2.py3",
"py3",
"py3.10",
"py310",
"source",
]

assert sorted(hashin.expand_python_version("3.12")) == [
"3.12",
"cp312",
"py2.py3",
"py3",
"py3.12",
"py312",
"source",
]


def test_get_package_hashes(murlopen):
def mocked_get(url, **options):
Expand Down