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: better repr string for pythonic projects #2297

Merged
merged 1 commit into from
Sep 20, 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/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
Loading