diff --git a/packages/testing/src/execution_testing/client_clis/ethereum_cli.py b/packages/testing/src/execution_testing/client_clis/ethereum_cli.py index c2ca9d11d5..c15671519d 100644 --- a/packages/testing/src/execution_testing/client_clis/ethereum_cli.py +++ b/packages/testing/src/execution_testing/client_clis/ethereum_cli.py @@ -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) @@ -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 diff --git a/packages/testing/src/execution_testing/client_clis/tests/test_ethereum_cli.py b/packages/testing/src/execution_testing/client_clis/tests/test_ethereum_cli.py new file mode 100644 index 0000000000..1770f74be3 --- /dev/null +++ b/packages/testing/src/execution_testing/client_clis/tests/test_ethereum_cli.py @@ -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()