Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: error message was incorrectly worded when Python package not installed #2242

Merged
merged 1 commit into from
Aug 23, 2024
Merged
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
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
Loading