Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Czaki committed Feb 7, 2024
1 parent 6ba5099 commit d0d99c6
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
24 changes: 24 additions & 0 deletions delocate/tests/test_delocating.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
from typing import Any, Callable, Dict, Iterable, List, Set, Text, Tuple

import pytest
from packaging.utils import InvalidWheelFilename
from packaging.version import Version

from ..delocating import (
DelocationError,
_get_archs_and_version_from_wheel_name,
bads_report,
check_archs,
copy_recurse,
Expand Down Expand Up @@ -705,3 +708,24 @@ def test_dyld_fallback_library_path_loses_to_basename() -> None:
# tmpdir can end up in /var, and that can be symlinked to
# /private/var, so we'll use realpath to resolve the two
assert_equal(predicted_lib_location, os.path.realpath(libb))


def test_get_archs_and_version_from_wheel_name() -> None:
# Test getting archs and version from wheel name
assert _get_archs_and_version_from_wheel_name(
"foo-1.0-py310-abi3-macosx_10_9_universal2.whl"
) == {
"universal2": Version("10.9"),
}
assert _get_archs_and_version_from_wheel_name(
"foo-1.0-py310-abi3-macosx_12_0_arm64.whl"
) == {
"arm64": Version("12.0"),
}
with pytest.raises(InvalidWheelFilename, match="Invalid wheel filename"):
_get_archs_and_version_from_wheel_name("foo.whl")

with pytest.raises(ValueError, match="Invalid platform tag"):
_get_archs_and_version_from_wheel_name(
"foo-1.0-py310-abi3-manylinux1.whl"
)
32 changes: 32 additions & 0 deletions delocate/tests/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,3 +738,35 @@ def test_delocate_wheel_verify_name_universal2_verify_crash(
assert result.returncode != 0
assert "Library dependencies do not satisfy target MacOS" in result.stderr
assert "libam1.dylib has a minimum target of 12.0" in result.stderr


@pytest.mark.xfail( # type: ignore[misc]
sys.platform != "darwin", reason="Needs macOS linkage."
)
@pytest.mark.script_launch_mode("subprocess")
def test_delocate_wheel_verify_name_universal2_verify_crash_env_var(
plat_wheel: PlatWheel,
script_runner: ScriptRunner,
tmp_path: Path,
monkeypatch: pytest.MonkeyPatch,
) -> None:
zip2dir(plat_wheel.whl, tmp_path / "plat")
shutil.copy(
DATA_PATH / "libam1_12.dylib",
tmp_path / "plat" / "fakepkg1" / "libam1.dylib",
)
whl_10_9 = tmp_path / "plat2-1.0-cp311-cp311-macosx_10_9_universal2.whl"
dir2zip(tmp_path / "plat", whl_10_9)
result = script_runner.run(
[
"delocate-wheel",
whl_10_9,
],
check=False,
cwd=tmp_path,
env={"MACOSX_DEPLOYMENT_TARGET": "10.9"},
shell=True,
)
assert result.returncode != 0
assert "Library dependencies do not satisfy target MacOS" in result.stderr
assert "libam1.dylib has a minimum target of 12.0" in result.stderr

0 comments on commit d0d99c6

Please sign in to comment.