|
1 | 1 | from __future__ import annotations
|
2 | 2 |
|
3 | 3 | import re
|
| 4 | +import tempfile |
| 5 | +from pathlib import Path |
4 | 6 |
|
5 | 7 | import pytest
|
6 | 8 |
|
7 | 9 | from auditwheel.architecture import Architecture
|
8 | 10 | from auditwheel.error import NonPlatformWheel
|
9 | 11 | from auditwheel.libc import Libc
|
10 | 12 | from auditwheel.wheeltools import (
|
| 13 | + InWheelCtx, |
11 | 14 | WheelToolsError,
|
12 | 15 | get_wheel_architecture,
|
13 | 16 | get_wheel_libc,
|
14 | 17 | )
|
15 | 18 |
|
| 19 | +HERE = Path(__file__).parent.resolve() |
| 20 | + |
16 | 21 |
|
17 | 22 | @pytest.mark.parametrize(
|
18 | 23 | ("filename", "expected"),
|
@@ -76,3 +81,19 @@ def test_get_wheel_libc_multiple(filename: str) -> None:
|
76 | 81 | match = re.escape("multiple libc are not supported")
|
77 | 82 | with pytest.raises(WheelToolsError, match=match):
|
78 | 83 | get_wheel_libc(filename)
|
| 84 | + |
| 85 | + |
| 86 | +def test_inwheel_tmpdir(tmp_path, monkeypatch): |
| 87 | + wheel_path = ( |
| 88 | + HERE |
| 89 | + / "../integration/arch-wheels/glibc/testsimple-0.0.1-cp313-cp313-linux_x86_64.whl" |
| 90 | + ) |
| 91 | + tmp_path = tmp_path.resolve(strict=True) |
| 92 | + tmpdir = tmp_path / "tmpdir" |
| 93 | + tmpdir.mkdir() |
| 94 | + tmpdir_symlink = tmp_path / "symlink" |
| 95 | + tmpdir_symlink.symlink_to(str(tmpdir), target_is_directory=True) |
| 96 | + monkeypatch.setattr(tempfile, "gettempdir", lambda: str(tmpdir_symlink)) |
| 97 | + with InWheelCtx(wheel_path, tmp_path / wheel_path.name) as context: |
| 98 | + Path(context._tmpdir.name).relative_to(tmpdir_symlink) |
| 99 | + context.name.relative_to(tmpdir) |
0 commit comments