-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_installer_binary_contracts.py
More file actions
56 lines (47 loc) · 1.84 KB
/
test_installer_binary_contracts.py
File metadata and controls
56 lines (47 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import inspect
from abxpkg import (
CargoProvider,
GemProvider,
GoGetProvider,
NixProvider,
NpmProvider,
PipProvider,
PlaywrightProvider,
PnpmProvider,
PuppeteerProvider,
PyinfraProvider,
)
def _installer_source(provider_cls) -> str:
return inspect.getsource(provider_cls.INSTALLER_BINARY)
class TestInstallerBinaryContracts:
def test_external_installer_providers_delegate_to_base_resolver(self):
for provider_cls in (
CargoProvider,
GemProvider,
GoGetProvider,
NixProvider,
NpmProvider,
PipProvider,
PyinfraProvider,
):
assert "super().INSTALLER_BINARY" in _installer_source(provider_cls)
def test_pnpm_provider_resolves_installer_without_base_recursion(self):
provider = PnpmProvider(postinstall_scripts=True, min_release_age=0)
abspath = provider.get_abspath("pnpm", quiet=True, no_cache=True)
installer = provider.INSTALLER_BINARY(no_cache=True)
assert abspath is not None
assert installer.loaded_binprovider is not None
assert installer.loaded_abspath == abspath
assert installer.loaded_binprovider.name == "env"
def test_browser_providers_do_not_delegate_to_base_resolver(self):
for provider_cls in (PlaywrightProvider, PuppeteerProvider):
assert "super().INSTALLER_BINARY" not in _installer_source(provider_cls)
def test_browser_providers_check_shared_lib_dir_then_raise_for_setup_bootstrap(
self,
):
for provider_cls in (PlaywrightProvider, PuppeteerProvider):
source = _installer_source(provider_cls)
assert "BinProviderUnavailableError" in source
assert "Path(lib_dir)" in source
assert '/ "pnpm"' in source
assert '/ "packages"' in source