Skip to content

Commit 80c640b

Browse files
authored
Merge pull request #8067 from deveshks/fix-create-basic-wheel-bug
Canonicalise package name in tests.lib.create_basic_wheel_for_package
2 parents 3ec6b82 + 22878a8 commit 80c640b

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

news/FCD7E4ED-BA3E-4018-B43E-D445DA8E542B.trivial

Whitespace-only changes.

tests/functional/test_install_wheel.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,3 +619,16 @@ def test_wheel_install_fails_with_badly_encoded_metadata(script):
619619
assert "Error decoding metadata for" in result.stderr
620620
assert "simple-0.1.0-py2.py3-none-any.whl" in result.stderr
621621
assert "METADATA" in result.stderr
622+
623+
624+
@pytest.mark.parametrize(
625+
'package_name',
626+
['simple-package', 'simple_package'],
627+
)
628+
def test_correct_package_name_while_creating_wheel_bug(script, package_name):
629+
"""Check that the package name is correctly named while creating
630+
a .whl file with a given format
631+
"""
632+
package = create_basic_wheel_for_package(script, package_name, '1.0')
633+
wheel_name = os.path.basename(package)
634+
assert wheel_name == 'simple_package-1.0-py2.py3-none-any.whl'

tests/lib/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,9 @@ def create_basic_wheel_for_package(
10021002
if extra_files is None:
10031003
extra_files = {}
10041004

1005+
# Fix wheel distribution name by replacing runs of non-alphanumeric
1006+
# characters with an underscore _ as per PEP 491
1007+
name = re.sub(r"[^\w\d.]+", "_", name, re.UNICODE)
10051008
archive_name = "{}-{}-py2.py3-none-any.whl".format(name, version)
10061009
archive_path = script.scratch_path / archive_name
10071010

0 commit comments

Comments
 (0)