Skip to content

Commit

Permalink
fix: better repr for pythonic projects
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Sep 20, 2024
1 parent b675967 commit b3443ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/ape/managers/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -2167,7 +2167,7 @@ def __init__(

@log_instead_of_fail(default="<ProjectManager>")
def __repr__(self):
path = f" {clean_path(self.path)}"
path = f" {clean_path(self._base_path)}"
# NOTE: 'Project' is meta for 'ProjectManager' (mixin magic).
return f"<ProjectManager{path}>"

Expand Down
14 changes: 9 additions & 5 deletions tests/functional/test_project.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
import re
import shutil
from pathlib import Path

Expand Down Expand Up @@ -107,14 +108,17 @@ def test_path_configured(project):
abi = [{"name": "foo", "type": "fallback", "stateMutability": "nonpayable"}]
contract.write_text(json.dumps(abi), encoding="utf8")

snekmate = Project(
snakemate = Project(
temp_dir, config_override={"base_path": "src", "contracts_folder": madeup_name}
)
assert snekmate.name == madeup_name
assert snekmate.path == subdir
assert snekmate.contracts_folder == contracts_folder
assert snakemate.name == madeup_name
assert snakemate.path == subdir
assert snakemate.contracts_folder == contracts_folder

actual = snekmate.load_contracts()
# The repr should show `/snakemate` and not `/snakemate/src/`.
assert re.match(r"<ProjectManager [\w|/]*/snakemate>", repr(snakemate))

actual = snakemate.load_contracts()
assert "snake" in actual
assert actual["snake"].source_id == f"{madeup_name}/snake.json"

Expand Down

0 comments on commit b3443ca

Please sign in to comment.