Skip to content

Commit a59316f

Browse files
committed
add unit test for get_wheel_architecture
1 parent 8db479d commit a59316f

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/unit/test_wheeltools.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from __future__ import annotations
2+
3+
import re
4+
5+
import pytest
6+
7+
from auditwheel.architecture import Architecture
8+
from auditwheel.error import NonPlatformWheel
9+
from auditwheel.wheeltools import WheelToolsError, get_wheel_architecture
10+
11+
12+
@pytest.mark.parametrize(
13+
("filename", "expected"),
14+
[(f"foo-1.0-py3-none-linux_{arch}.whl", arch) for arch in Architecture]
15+
+ [("foo-1.0-py3-none-linux_x86_64.manylinux1_x86_64.whl", Architecture.x86_64)],
16+
)
17+
def test_get_wheel_architecture(filename: str, expected: Architecture) -> None:
18+
arch = get_wheel_architecture(filename)
19+
assert arch == expected.baseline
20+
21+
22+
def test_get_wheel_architecture_unknown() -> None:
23+
with pytest.raises(WheelToolsError, match=re.escape("unknown architecture")):
24+
get_wheel_architecture("foo-1.0-py3-none-linux_mipsel.whl")
25+
26+
27+
def test_get_wheel_architecture_pure() -> None:
28+
with pytest.raises(NonPlatformWheel):
29+
get_wheel_architecture("foo-1.0-py3-none-any.whl")
30+
31+
32+
@pytest.mark.parametrize(
33+
"filename",
34+
[
35+
"foo-1.0-py3-none-linux_x86_64.linux_aarch64.whl",
36+
"foo-1.0-py3-none-linux_x86_64.linux_mipsel.whl",
37+
"foo-1.0-py3-none-linux_x86_64.any.whl",
38+
],
39+
)
40+
def test_get_wheel_architecture_multiple(filename: str) -> None:
41+
match = re.escape("multiple architectures are not supported")
42+
with pytest.raises(WheelToolsError, match=match):
43+
get_wheel_architecture(filename)

0 commit comments

Comments
 (0)