1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
From: Colin Watson <cjwatson@debian.org>
Date: Mon, 1 Dec 2025 09:53:00 +0000
Subject: fix: architecture tests on 32-bit x86
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.
Forwarded: https://github.com/pypa/auditwheel/pull/640
Last-Update: 2025-12-01
---
tests/integration/test_bundled_wheels.py | 3 +--
tests/unit/test_main.py | 6 +++---
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/tests/integration/test_bundled_wheels.py b/tests/integration/test_bundled_wheels.py
index 046b8fc..b81a5a7 100644
--- a/tests/integration/test_bundled_wheels.py
+++ b/tests/integration/test_bundled_wheels.py
@@ -2,7 +2,6 @@ from __future__ import annotations
import importlib
import os
-import platform
import sys
import zipfile
from argparse import Namespace
@@ -108,7 +107,7 @@ def test_analyze_wheel_abi_pyfpe():
def test_show_wheel_abi_pyfpe(monkeypatch, capsys):
wheel = str(HERE / "fpewheel-0.0.0-cp35-cp35m-linux_x86_64.whl")
monkeypatch.setattr(sys, "platform", "linux")
- monkeypatch.setattr(platform, "machine", lambda: "x86_64")
+ monkeypatch.setattr(Architecture, "detect", lambda: Architecture.x86_64)
monkeypatch.setattr(sys, "argv", ["auditwheel", "show", wheel])
assert main() == 0
captured = capsys.readouterr()
diff --git a/tests/unit/test_main.py b/tests/unit/test_main.py
index bdaa910..3aaa417 100644
--- a/tests/unit/test_main.py
+++ b/tests/unit/test_main.py
@@ -1,10 +1,10 @@
from __future__ import annotations
-import platform
import sys
import pytest
+from auditwheel.architecture import Architecture
from auditwheel.libc import Libc, LibcVersion
from auditwheel.main import main
@@ -41,7 +41,7 @@ def test_help(monkeypatch, capsys):
@pytest.mark.parametrize("function", ["show", "repair"])
def test_unexisting_wheel(monkeypatch, capsys, tmp_path, function):
monkeypatch.setattr(sys, "platform", "linux")
- monkeypatch.setattr(platform, "machine", lambda: "x86_64")
+ monkeypatch.setattr(Architecture, "detect", lambda: Architecture.x86_64)
wheel = str(tmp_path / "not-a-file.whl")
monkeypatch.setattr(sys, "argv", ["auditwheel", function, wheel])
@@ -79,7 +79,7 @@ def test_repair_wheel_mismatch(
monkeypatch, capsys, tmp_path, libc, filename, plat, message
):
monkeypatch.setattr(sys, "platform", "linux")
- monkeypatch.setattr(platform, "machine", lambda: "x86_64")
+ monkeypatch.setattr(Architecture, "detect", lambda: Architecture.x86_64)
monkeypatch.setattr(Libc, "detect", lambda: libc)
monkeypatch.setattr(Libc, "get_current_version", lambda _: LibcVersion(1, 1))
wheel = tmp_path / filename
|