Skip to content

Commit 5b18e35

Browse files
authored
fix: architecture tests on 32-bit x86 (#640)
Some tests that involved monkey-patching architecture detection failed on 32-bit x86 (as seen in e.g. https://ci.debian.net/packages/p/python-auditwheel/testing/i386/66694877/), because they tried to set the architecture by monkey-patching `platform.machine`, but `Architecture.detect` also cares about the size of pointers. It's simpler and more reliable to just monkey-patch `Architecture.detect` directly in these cases.
1 parent a70f480 commit 5b18e35

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

tests/integration/test_bundled_wheels.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import importlib
44
import os
5-
import platform
65
import sys
76
import zipfile
87
from argparse import Namespace
@@ -108,7 +107,7 @@ def test_analyze_wheel_abi_pyfpe():
108107
def test_show_wheel_abi_pyfpe(monkeypatch, capsys):
109108
wheel = str(HERE / "fpewheel-0.0.0-cp35-cp35m-linux_x86_64.whl")
110109
monkeypatch.setattr(sys, "platform", "linux")
111-
monkeypatch.setattr(platform, "machine", lambda: "x86_64")
110+
monkeypatch.setattr(Architecture, "detect", lambda: Architecture.x86_64)
112111
monkeypatch.setattr(sys, "argv", ["auditwheel", "show", wheel])
113112
assert main() == 0
114113
captured = capsys.readouterr()

tests/unit/test_main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from __future__ import annotations
22

3-
import platform
43
import sys
54

65
import pytest
76

7+
from auditwheel.architecture import Architecture
88
from auditwheel.libc import Libc, LibcVersion
99
from auditwheel.main import main
1010

@@ -41,7 +41,7 @@ def test_help(monkeypatch, capsys):
4141
@pytest.mark.parametrize("function", ["show", "repair"])
4242
def test_unexisting_wheel(monkeypatch, capsys, tmp_path, function):
4343
monkeypatch.setattr(sys, "platform", "linux")
44-
monkeypatch.setattr(platform, "machine", lambda: "x86_64")
44+
monkeypatch.setattr(Architecture, "detect", lambda: Architecture.x86_64)
4545
wheel = str(tmp_path / "not-a-file.whl")
4646
monkeypatch.setattr(sys, "argv", ["auditwheel", function, wheel])
4747

@@ -79,7 +79,7 @@ def test_repair_wheel_mismatch(
7979
monkeypatch, capsys, tmp_path, libc, filename, plat, message
8080
):
8181
monkeypatch.setattr(sys, "platform", "linux")
82-
monkeypatch.setattr(platform, "machine", lambda: "x86_64")
82+
monkeypatch.setattr(Architecture, "detect", lambda: Architecture.x86_64)
8383
monkeypatch.setattr(Libc, "detect", lambda: libc)
8484
monkeypatch.setattr(Libc, "get_current_version", lambda _: LibcVersion(1, 1))
8585
wheel = tmp_path / filename

0 commit comments

Comments
 (0)