Skip to content
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
4 changes: 3 additions & 1 deletion src/ape/managers/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,9 @@ def get(
if check_for_changes and self._detect_change(source_id):
compiled = {
ct.name: ct
for ct in self.compiler_manager.compile(source_id, project=self.project)
for ct in self.compiler_manager.compile(
self.project.path / source_id, project=self.project
)
if ct.name
}
if compiled:
Expand Down
18 changes: 18 additions & 0 deletions tests/functional/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,24 @@ def test_values(self, small_temp_project):
new_count = len(small_temp_project.contracts)
assert new_count == count - 1

def test_get_after_change_from_other_cwd(self, small_temp_project):
# Regression: getting a contract whose source has changed must not
# depend on cwd happening to equal the project root.
small_temp_project.load_contracts(use_cache=False)
source_path = small_temp_project.contracts_folder / "Other.json"
source_path.write_text(source_path.read_text(encoding="utf8") + "\n", encoding="utf8")

original_cwd = Path.cwd()
with create_tempdir() as elsewhere:
os.chdir(elsewhere)
try:
actual = small_temp_project.contracts.get("Other")
finally:
os.chdir(original_cwd)

assert isinstance(actual, ContractContainer)
assert actual.contract_type.name == "Other"


class TestDeploymentManager:
def test_track(self, project, owner):
Expand Down
Loading