Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(self, *, binary: Optional[Path] = None):
resolved_path = Path(os.path.expanduser(binary)).resolve()
if resolved_path.exists():
binary = resolved_path
binary = shutil.which(binary) # type: ignore
binary = shutil.which(str(binary)) # type: ignore
if not binary:
raise CLINotFoundInPathError(binary=binary)
self.binary = Path(binary)
Expand Down Expand Up @@ -239,7 +239,7 @@ def is_installed(cls, binary_path: Optional[Path] = None) -> bool:
resolved_path = Path(os.path.expanduser(binary_path)).resolve()
if resolved_path.exists():
binary_path = resolved_path
binary = shutil.which(binary_path)
binary = shutil.which(str(binary_path))
return binary is not None

@classmethod
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Tests for the `EthereumCLI` base class."""

from pathlib import Path

import pytest

from execution_testing.client_clis.ethereum_cli import (
CLINotFoundInPathError,
EthereumCLI,
)


class _MissingCLI(EthereumCLI):
"""A CLI whose binary is guaranteed not to be on `PATH`."""

default_binary = Path("eels-nonexistent-binary-xyz")


def test_is_installed_accepts_path_binary() -> None:
"""`is_installed` handles a `Path` binary without raising."""
# `shutil.which` must receive a `str`; a `Path` crashes on some
# platforms (e.g. Windows under Python 3.11).
assert _MissingCLI.is_installed() is False


def test_init_missing_path_binary_raises_cli_not_found() -> None:
"""Constructing a CLI with a missing `Path` binary raises cleanly."""
with pytest.raises(CLINotFoundInPathError):
_MissingCLI()