Skip to content

Commit

Permalink
fix npm tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pirate committed Aug 30, 2024
1 parent 74944f4 commit 37c23bc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pydantic_pkgr/binprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,10 +562,10 @@ def install(self, bin_name: BinName, overrides: Optional[ProviderLookupDict]=Non
)

installed_abspath = self.get_abspath(bin_name, overrides=overrides)
assert installed_abspath, f'Unable to find {bin_name} abspath after installing with {self.name}'
assert installed_abspath, f'{self.__class__.__name__} Unable to find abspath for {bin_name} after installing. PATH={self.PATH}'

installed_version = self.get_version(bin_name, overrides=overrides, abspath=installed_abspath)
assert installed_version, f'Unable to find {bin_name} version after installing with {self.name}'
assert installed_version, f'{self.__class__.__name__} Unable to find version for {bin_name} after installing. ABSPATH={installed_abspath}'

result = ShallowBinary(
name=bin_name,
Expand Down
9 changes: 6 additions & 3 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,11 @@ def install_with_binprovider(self, provider, binary):
self.assertIn(binary_bin.loaded_abspath, flatten(binary_bin.loaded_abspaths.values()))
self.assertIn(str(binary_bin.bin_dir), flatten(PATH.split(':') for PATH in binary_bin.loaded_bin_dirs.values()))

VERSION = SemVer.parse(subprocess.check_output(f'{binary.name} --version', shell=True, text=True))
ABSPATH = Path(shutil.which(binary.name)).absolute().resolve()
PATH = provider.PATH
bin_abspath = shutil.which(binary.name, path=PATH)

VERSION = SemVer.parse(subprocess.check_output(f'{bin_abspath} --version', shell=True, text=True))
ABSPATH = Path(bin_abspath).absolute().resolve()

self.assertEqual(binary_bin.loaded_version, VERSION)
self.assertIn(binary_bin.loaded_abspath, provider.get_abspaths(binary_bin.name))
Expand Down Expand Up @@ -226,7 +229,7 @@ def test_pip_provider(self):
def test_npm_provider(self):
npmprovider = NpmProvider()
# print(provider.PATH)
binary = Binary(name='single-file', binproviders=[npmprovider], overrides={'npm': {'packages': lambda: ['single-file-cli']}})
binary = Binary(name='tsx', binproviders=[npmprovider])
self.install_with_binprovider(npmprovider, binary)

def test_brew_provider(self):
Expand Down

0 comments on commit 37c23bc

Please sign in to comment.