Skip to content

Commit 8a0413f

Browse files
committed
add unit test for get_wheel_libc
1 parent a59316f commit 8a0413f

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

tests/unit/test_wheeltools.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66

77
from auditwheel.architecture import Architecture
88
from auditwheel.error import NonPlatformWheel
9-
from auditwheel.wheeltools import WheelToolsError, get_wheel_architecture
9+
from auditwheel.libc import Libc
10+
from auditwheel.wheeltools import (
11+
WheelToolsError,
12+
get_wheel_architecture,
13+
get_wheel_libc,
14+
)
1015

1116

1217
@pytest.mark.parametrize(
@@ -41,3 +46,33 @@ def test_get_wheel_architecture_multiple(filename: str) -> None:
4146
match = re.escape("multiple architectures are not supported")
4247
with pytest.raises(WheelToolsError, match=match):
4348
get_wheel_architecture(filename)
49+
50+
51+
@pytest.mark.parametrize(
52+
("filename", "expected"),
53+
[
54+
("foo-1.0-py3-none-manylinux1_x86_64.whl", Libc.GLIBC),
55+
("foo-1.0-py3-none-manylinux1_x86_64.manylinux2010_x86_64.whl", Libc.GLIBC),
56+
("foo-1.0-py3-none-musllinux_1_1_x86_64.whl", Libc.MUSL),
57+
],
58+
)
59+
def test_get_wheel_libc(filename: str, expected: Libc) -> None:
60+
libc = get_wheel_libc(filename)
61+
assert libc == expected
62+
63+
64+
@pytest.mark.parametrize(
65+
"filename", ["foo-1.0-py3-none-any.whl", "foo-1.0-py3-none-something.whl"]
66+
)
67+
def test_get_wheel_libc_unknown(filename: str) -> None:
68+
with pytest.raises(WheelToolsError, match=re.escape("unknown libc used")):
69+
get_wheel_libc(filename)
70+
71+
72+
@pytest.mark.parametrize(
73+
"filename", ["foo-1.0-py3-none-manylinux1_x86_64.musllinux_1_1_x86_64.whl"]
74+
)
75+
def test_get_wheel_libc_multiple(filename: str) -> None:
76+
match = re.escape("multiple libc are not supported")
77+
with pytest.raises(WheelToolsError, match=match):
78+
get_wheel_libc(filename)

0 commit comments

Comments
 (0)