Skip to content

Commit

Permalink
fix: error message was incorrectly worded when Python package not ins…
Browse files Browse the repository at this point in the history
…talled (#2242)
  • Loading branch information
antazoey authored Aug 23, 2024
1 parent 9dc19e1 commit 817aa0b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ape_pm/dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def version_id(self) -> str:
try:
vers = f"{metadata.version(self.python)}"
except metadata.PackageNotFoundError as err:
raise ProjectError(f"Dependency '{self.python}' not found installed.") from err
raise ProjectError(f"Dependency '{self.python}' not installed.") from err

if spec_vers := self.version:
if spec_vers != vers:
Expand Down
8 changes: 8 additions & 0 deletions tests/functional/test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pydantic import ValidationError

import ape
from ape.exceptions import ProjectError
from ape.managers.project import Dependency, LocalProject, PackagesCache, Project, ProjectManager
from ape.utils import create_tempdir
from ape_pm.dependency import GithubDependency, LocalDependency, NpmDependency, PythonDependency
Expand Down Expand Up @@ -594,6 +595,13 @@ def test_version_id(self, web3_dependency):
assert actual[0].isnumeric()
assert "." in actual # sep from minor / major / patch

def test_version_id_not_found(self):
name = "xxthisnameisnotarealpythonpackagexx"
dependency = PythonDependency.model_validate({"python": name})
expected = f"Dependency '{name}' not installed."
with pytest.raises(ProjectError, match=expected):
_ = dependency.version_id

def test_fetch(self, web3_dependency):
with create_tempdir() as temp_dir:
web3_dependency.fetch(temp_dir)
Expand Down

0 comments on commit 817aa0b

Please sign in to comment.