|
4 | 4 |
|
5 | 5 |
|
6 | 6 | import collections.abc
|
| 7 | +import subprocess |
7 | 8 |
|
8 | 9 | try:
|
9 | 10 | import ctypes
|
@@ -230,12 +231,48 @@ def test_version_detection(self, monkeypatch):
|
230 | 231 | version = platform.mac_ver()[0].split(".")
|
231 | 232 | major = version[0]
|
232 | 233 | minor = version[1] if major == "10" else "0"
|
233 |
| - expected = f"macosx_{major}_{minor}" |
| 234 | + |
| 235 | + platforms = list(tags.mac_platforms(arch="x86_64")) |
| 236 | + if (major, minor) == ("10", "16"): |
| 237 | + print(platforms, "macosx_11+") |
| 238 | + # For 10.16, the real version is at least 11.0. |
| 239 | + prefix, major, minor, _ = platforms[0].split("_", maxsplit=3) |
| 240 | + assert prefix == "macosx" |
| 241 | + assert int(major) >= 11 |
| 242 | + assert minor == "0" |
| 243 | + else: |
| 244 | + expected = f"macosx_{major}_{minor}_" |
| 245 | + print(platforms, expected) |
| 246 | + assert platforms[0].startswith(expected) |
| 247 | + |
| 248 | + def test_version_detection_10_15(self, monkeypatch): |
| 249 | + monkeypatch.setattr( |
| 250 | + platform, "mac_ver", lambda: ("10.15", ("", "", ""), "x86_64") |
| 251 | + ) |
| 252 | + expected = "macosx_10_15_" |
234 | 253 |
|
235 | 254 | platforms = list(tags.mac_platforms(arch="x86_64"))
|
236 | 255 | print(platforms, expected)
|
237 | 256 | assert platforms[0].startswith(expected)
|
238 | 257 |
|
| 258 | + def test_version_detection_compatibility(self, monkeypatch): |
| 259 | + if platform.system() != "Darwin": |
| 260 | + monkeypatch.setattr( |
| 261 | + subprocess, |
| 262 | + "run", |
| 263 | + lambda *args, **kwargs: subprocess.CompletedProcess( |
| 264 | + [], 0, stdout="10.15" |
| 265 | + ), |
| 266 | + ) |
| 267 | + monkeypatch.setattr( |
| 268 | + platform, "mac_ver", lambda: ("10.16", ("", "", ""), "x86_64") |
| 269 | + ) |
| 270 | + unexpected = "macosx_10_16_" |
| 271 | + |
| 272 | + platforms = list(tags.mac_platforms(arch="x86_64")) |
| 273 | + print(platforms, unexpected) |
| 274 | + assert not platforms[0].startswith(unexpected) |
| 275 | + |
239 | 276 | @pytest.mark.parametrize("arch", ["x86_64", "i386"])
|
240 | 277 | def test_arch_detection(self, arch, monkeypatch):
|
241 | 278 | if platform.system() != "Darwin" or platform.mac_ver()[2] != arch:
|
|
0 commit comments