Debian Codegraph @

tests/transitive/test_transitive.py

raw
1 import sys
2 import typing
3 from pathlib import Path
4
5 import findlibs
6
7
8 def test_transitive(monkeypatch) -> None:
9 """There is a module modAlibs in this directory that mocks expected bin wheel contract:
10 - modulename ends with 'lib'
11 - contains libmodA.so
12 - inside __init__ there is the findlibs_dependencies, containing modBlib
13 This test checks that when such module is findlibs-found, the (mock) ld loaded the libmodB
14 """
15
16 # so that modAlibs and modBlibs are visible
17 sys.path.append(str(Path(__file__).parent))
18
19 # the files in test are not real .so, we thus just track what got loaded
20 loaded_libs = set()
21
22 def libload_accumulator(path: str, mode: typing.Any):
23 loaded_libs.add(path)
24
25 monkeypatch.setattr(findlibs, "CDLL", libload_accumulator)
26 monkeypatch.setattr(
27 sys, "platform", "tests"
28 ) # this makes the test behave like linux default
29
30 # test
31 found = findlibs.find("modA")
32 expected_found = str(Path(__file__).parent / "modAlib" / "lib64" / "libmodA.so")
33 assert found == expected_found
34
35 expected_dylib = str(Path(__file__).parent / "modBlib" / "lib64" / "libmodB.so")
36 assert loaded_libs == {expected_dylib}