From 13ea95253a75d9576d5f89f6378254abda200e9e Mon Sep 17 00:00:00 2001 From: antazoey Date: Fri, 20 Sep 2024 09:52:04 -0500 Subject: [PATCH] fix: better repr string for pythonic projects (#2297) --- src/ape/managers/project.py | 2 +- tests/functional/test_project.py | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/ape/managers/project.py b/src/ape/managers/project.py index c63f1192ad..0d0c4d9a8b 100644 --- a/src/ape/managers/project.py +++ b/src/ape/managers/project.py @@ -2167,7 +2167,7 @@ def __init__( @log_instead_of_fail(default="") 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"" diff --git a/tests/functional/test_project.py b/tests/functional/test_project.py index a948765dd7..77693e6324 100644 --- a/tests/functional/test_project.py +++ b/tests/functional/test_project.py @@ -1,5 +1,6 @@ import json import os +import re import shutil from pathlib import Path @@ -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"", repr(snakemate)) + + actual = snakemate.load_contracts() assert "snake" in actual assert actual["snake"].source_id == f"{madeup_name}/snake.json"