Skip to content

Commit

Permalink
fix: issue with --force flag on ape pm commands (#2119)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Jun 6, 2024
1 parent a3e26ab commit 29269bc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/ape/managers/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,7 @@ def install(self, **dependency: Any) -> Union[Dependency, list[Dependency]]:
:class:`~ape.managers.project.Dependency` when given data else a list
of them, one for each specified.
"""
use_cache: bool = dependency.pop("use_cache", False)
use_cache: bool = dependency.pop("use_cache", True)
if dependency:
return self.install_dependency(dependency, use_cache=use_cache)

Expand Down
17 changes: 13 additions & 4 deletions tests/functional/test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,14 @@ def test_install(project, mocker):
contracts_path.mkdir(exist_ok=True, parents=True)
(contracts_path / "contract.json").write_text('{"abi": []}')
data = {"name": "FooBar", "local": f"{tmp_project.path}"}
get_spec_spy = mocker.spy(tmp_project.dependencies, "_get_specified")
install_dep_spy = mocker.spy(tmp_project.dependencies, "install_dependency")

# Show can install from DependencyManager.
dependency = tmp_project.dependencies.install(**data)
assert isinstance(dependency, Dependency)
# NOTE: Here, we are mostly testing that `use_cache=False` was not passed.
assert install_dep_spy.call_count == 1

# Show can install from Dependency.
project = dependency.install()
Expand All @@ -236,9 +240,8 @@ def test_install(project, mocker):
assert dependency.project_path.is_dir() # Was re-created from manifest sources.

# Force install and prove it actually does the re-install.
spy = mocker.spy(tmp_project.dependencies, "_get_specified")
tmp_project.dependencies.install(use_cache=False)
spy.assert_called_once_with(use_cache=False)
get_spec_spy.assert_called_once_with(use_cache=False)


def test_install_dependencies_of_dependencies(project, with_dependencies_project_path):
Expand Down Expand Up @@ -580,13 +583,19 @@ def test_load_contracts_with_config_override(self, project):
contracts_path = tmp_project.path / "src"
contracts_path.mkdir(exist_ok=True, parents=True)
(contracts_path / "contract.json").write_text('{"abi": []}')
data = {"name": "FooBar", "local": f"{tmp_project.path}", "config_override": override}

# use_cache=False only to lessen stateful test clobbering.
data = {
"name": "FooBar",
"local": f"{tmp_project.path}",
"config_override": override,
"use_cache": False,
}
tmp_project.dependencies.install(**data)
proj = tmp_project.dependencies.get("foobar", "local")
assert proj.config.contracts_folder == "src"

assert proj.contracts_folder == proj.path / "src"
assert proj.contracts_folder.is_dir()
assert [x.name for x in proj.sources.paths] == ["contract.json"]
actual = proj.load_contracts()
assert len(actual) > 0
Expand Down

0 comments on commit 29269bc

Please sign in to comment.