|
6 | 6 | import pytest |
7 | 7 |
|
8 | 8 | from abxpkg import ( |
| 9 | + BinName, |
| 10 | + BinProvider, |
| 11 | + BinProviderName, |
9 | 12 | BunProvider, |
10 | 13 | DenoProvider, |
11 | 14 | EnvProvider, |
@@ -79,6 +82,32 @@ def test_installer_binary_abspath_resolves_without_recursing( |
79 | 82 | assert installer.name == installer_bin |
80 | 83 | assert installer.loaded_version is not None |
81 | 84 |
|
| 85 | + def test_installer_binary_auto_installs_missing_dependency_into_configured_lib( |
| 86 | + self, |
| 87 | + monkeypatch, |
| 88 | + ): |
| 89 | + class BlackInstallerProvider(BinProvider): |
| 90 | + name: BinProviderName = "black_bootstrap" |
| 91 | + INSTALLER_BIN: BinName = "black" |
| 92 | + |
| 93 | + with tempfile.TemporaryDirectory() as tmpdir: |
| 94 | + tmpdir_path = Path(tmpdir) |
| 95 | + monkeypatch.setenv("ABXPKG_BINPROVIDERS", "pip") |
| 96 | + monkeypatch.setenv("ABXPKG_LIB_DIR", str(tmpdir_path / "abxlib")) |
| 97 | + |
| 98 | + installer = BlackInstallerProvider( |
| 99 | + postinstall_scripts=True, |
| 100 | + min_release_age=0, |
| 101 | + ).INSTALLER_BINARY(no_cache=True) |
| 102 | + |
| 103 | + assert installer.loaded_binprovider is not None |
| 104 | + assert installer.loaded_binprovider.name == "pip" |
| 105 | + assert installer.loaded_abspath is not None |
| 106 | + assert installer.loaded_abspath.resolve().is_relative_to( |
| 107 | + (tmpdir_path / "abxlib" / "pip" / "venv" / "bin").resolve(), |
| 108 | + ) |
| 109 | + assert installer.loaded_version is not None |
| 110 | + |
82 | 111 | def test_base_public_getters_resolve_real_host_python(self, test_machine): |
83 | 112 | provider = EnvProvider(postinstall_scripts=True, min_release_age=0) |
84 | 113 |
|
|
0 commit comments