Skip to content

Commit 0934b8f

Browse files
committed
test_analyze_wheel_abi: refactor test with explicit env
Be explicit in the test-case matrix when to set env variable. This enables to check if environment variable is actually correctly reset. This commit passes unit tests.
1 parent 8b41121 commit 0934b8f

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

tests/integration/test_bundled_wheels.py

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

33
import importlib
4-
import os
54
import platform
65
import sys
76
import zipfile
87
from argparse import Namespace
98
from datetime import datetime, timezone
10-
from os.path import isabs
119
from pathlib import Path
1210
from unittest.mock import Mock
1311

@@ -23,69 +21,76 @@
2321

2422

2523
@pytest.mark.parametrize(
26-
("file", "external_libs", "exclude"),
24+
("file", "external_libs", "exclude", "env"),
2725
[
2826
(
2927
"cffi-1.5.0-cp27-none-linux_x86_64.whl",
3028
{"libffi.so.5", "libpython2.7.so.1.0"},
3129
frozenset(),
30+
None,
3231
),
3332
(
3433
"cffi-1.5.0-cp27-none-linux_x86_64.whl",
3534
set(),
3635
frozenset(["libffi.so.5", "libpython2.7.so.1.0"]),
36+
None,
3737
),
3838
(
3939
"cffi-1.5.0-cp27-none-linux_x86_64.whl",
4040
{"libffi.so.5", "libpython2.7.so.1.0"},
4141
frozenset(["libffi.so.noexist", "libnoexist.so.*"]),
42+
None,
4243
),
4344
(
4445
"cffi-1.5.0-cp27-none-linux_x86_64.whl",
4546
{"libpython2.7.so.1.0"},
4647
frozenset(["libffi.so.[4,5]"]),
48+
None,
4749
),
4850
(
4951
"cffi-1.5.0-cp27-none-linux_x86_64.whl",
5052
{"libffi.so.5", "libpython2.7.so.1.0"},
5153
frozenset(["libffi.so.[6,7]"]),
54+
None,
5255
),
5356
(
5457
"cffi-1.5.0-cp27-none-linux_x86_64.whl",
5558
{"libpython2.7.so.1.0"},
5659
frozenset([f"{HERE}/*"]),
60+
"LD_LIBRARY_PATH",
5761
),
5862
(
5963
"cffi-1.5.0-cp27-none-linux_x86_64.whl",
6064
{"libpython2.7.so.1.0"},
6165
frozenset(["libffi.so.*"]),
66+
None,
6267
),
63-
("cffi-1.5.0-cp27-none-linux_x86_64.whl", set(), frozenset(["*"])),
68+
("cffi-1.5.0-cp27-none-linux_x86_64.whl", set(), frozenset(["*"]), None),
6469
(
6570
"python_snappy-0.5.2-pp260-pypy_41-linux_x86_64.whl",
6671
{"libsnappy.so.1"},
6772
frozenset(),
73+
None,
6874
),
6975
],
7076
)
71-
def test_analyze_wheel_abi(file, external_libs, exclude):
77+
def test_analyze_wheel_abi(file, external_libs, exclude, env):
7278
# If exclude libs contain path, LD_LIBRARY_PATH need to be modified to find the libs
7379
# `lddtree.load_ld_paths` needs to be reloaded for it's `lru_cache`-ed.
74-
modify_ld_library_path = any(isabs(e) for e in exclude)
7580

7681
with pytest.MonkeyPatch.context() as cp:
77-
if modify_ld_library_path:
78-
cp.setenv("LD_LIBRARY_PATH", f"{HERE}")
82+
if env:
83+
cp.setenv(env, f"{HERE}")
7984
importlib.reload(lddtree)
8085

8186
winfo = analyze_wheel_abi(
8287
Libc.GLIBC, Architecture.x86_64, HERE / file, exclude, False, True
8388
)
8489
assert set(winfo.external_refs["manylinux_2_5_x86_64"].libs) == external_libs, (
85-
f"{HERE}, {exclude}, {os.environ}"
90+
f"{HERE}, {exclude}, {env}"
8691
)
8792

88-
if modify_ld_library_path:
93+
if env:
8994
importlib.reload(lddtree)
9095

9196

0 commit comments

Comments
 (0)