|
5 | 5 |
|
6 | 6 | import pytest
|
7 | 7 |
|
| 8 | +from auditwheel.libc import Libc, LibcVersion |
8 | 9 | from auditwheel.main import main
|
9 | 10 |
|
10 | 11 | on_supported_platform = pytest.mark.skipif(
|
@@ -37,14 +38,58 @@ def test_help(monkeypatch, capsys):
|
37 | 38 | assert "usage: auditwheel [-h] [-V] [-v] command ..." in captured.out
|
38 | 39 |
|
39 | 40 |
|
40 |
| -def test_show_unexisting_wheel(monkeypatch, capsys, tmp_path): |
| 41 | +@pytest.mark.parametrize("function", ["show", "repair"]) |
| 42 | +def test_unexisting_wheel(monkeypatch, capsys, tmp_path, function): |
41 | 43 | monkeypatch.setattr(sys, "platform", "linux")
|
42 | 44 | monkeypatch.setattr(platform, "machine", lambda: "x86_64")
|
43 | 45 | wheel = str(tmp_path / "not-a-file.whl")
|
44 |
| - monkeypatch.setattr(sys, "argv", ["dummy", "show", wheel]) |
| 46 | + monkeypatch.setattr(sys, "argv", ["auditwheel", function, wheel]) |
45 | 47 |
|
46 | 48 | with pytest.raises(SystemExit):
|
47 | 49 | main()
|
48 | 50 |
|
49 | 51 | captured = capsys.readouterr()
|
50 | 52 | assert "No such file" in captured.err
|
| 53 | + |
| 54 | + |
| 55 | +@pytest.mark.parametrize( |
| 56 | + ("libc", "filename", "plat", "message"), |
| 57 | + [ |
| 58 | + ( |
| 59 | + Libc.GLIBC, |
| 60 | + "foo-1.0-py3-none-manylinux1_aarch64.whl", |
| 61 | + "manylinux_2_28_x86_64", |
| 62 | + "can't repair wheel foo-1.0-py3-none-manylinux1_aarch64.whl with aarch64 architecture to a wheel targeting x86_64", |
| 63 | + ), |
| 64 | + ( |
| 65 | + Libc.GLIBC, |
| 66 | + "foo-1.0-py3-none-musllinux_1_1_x86_64.whl", |
| 67 | + "manylinux_2_28_x86_64", |
| 68 | + "can't repair wheel foo-1.0-py3-none-musllinux_1_1_x86_64.whl with MUSL libc to a wheel targeting GLIBC", |
| 69 | + ), |
| 70 | + ( |
| 71 | + Libc.MUSL, |
| 72 | + "foo-1.0-py3-none-manylinux1_x86_64.whl", |
| 73 | + "musllinux_1_1_x86_64", |
| 74 | + "can't repair wheel foo-1.0-py3-none-manylinux1_x86_64.whl with GLIBC libc to a wheel targeting MUSL", |
| 75 | + ), |
| 76 | + ], |
| 77 | +) |
| 78 | +def test_repair_wheel_mismatch( |
| 79 | + monkeypatch, capsys, tmp_path, libc, filename, plat, message |
| 80 | +): |
| 81 | + monkeypatch.setattr(sys, "platform", "linux") |
| 82 | + monkeypatch.setattr(platform, "machine", lambda: "x86_64") |
| 83 | + monkeypatch.setattr(Libc, "detect", lambda: libc) |
| 84 | + monkeypatch.setattr(Libc, "get_current_version", lambda _: LibcVersion(1, 1)) |
| 85 | + wheel = tmp_path / filename |
| 86 | + wheel.write_text("") |
| 87 | + monkeypatch.setattr( |
| 88 | + sys, "argv", ["auditwheel", "repair", "--plat", plat, str(wheel)] |
| 89 | + ) |
| 90 | + |
| 91 | + with pytest.raises(SystemExit): |
| 92 | + main() |
| 93 | + |
| 94 | + captured = capsys.readouterr() |
| 95 | + assert message in captured.err |
0 commit comments