diff --git a/aea/components/base.py b/aea/components/base.py index c8bc915a4d..db51307a03 100644 --- a/aea/components/base.py +++ b/aea/components/base.py @@ -185,7 +185,7 @@ def _extract_imported_packages_as_ids( # import packages.{author}.{type_plural}.{name} # import_statements = re.findall( - rf"^(from|import) ({PACKAGES}\.[A-Za-z0-9_]+\.{cls.package_type_plural_regex}\.[A-Za-z0-9_]+)", + rf"^( from|from| import|import) ({PACKAGES}\.[A-Za-z0-9_]+\.{cls.package_type_plural_regex}\.[A-Za-z0-9_]+)", module_content, flags=re.MULTILINE, ) diff --git a/tests/data/packages/default_author/contracts/stub_1/contract.py b/tests/data/packages/default_author/contracts/stub_1/contract.py index 61cf6aea9c..bda1264d86 100644 --- a/tests/data/packages/default_author/contracts/stub_1/contract.py +++ b/tests/data/packages/default_author/contracts/stub_1/contract.py @@ -27,9 +27,15 @@ from aea.contracts.base import Contract from aea.crypto.base import LedgerApi -from packages.default_author.contracts.stub_0.contract import ( # type: ignore # noqa: F401 - MyScaffoldContract as MC, -) + +try: + from tests.data.packages.default_author.contracts.stub_0.contract import ( # type: ignore # noqa: F401 + MyScaffoldContract as MC, + ) +except ModuleNotFoundError: + from packages.default_author.contracts.stub_0.contract import ( # type: ignore # noqa: F401 + MyScaffoldContract as MC, + ) class MyScaffoldContract(Contract): @@ -41,7 +47,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: """Init contract.""" super().__init__(*args, **kwargs) print("Contract stub_1 initialized.") - raise Exception() + raise Exception("Raised on purpose!") @classmethod def get_raw_transaction( diff --git a/tests/data/packages/default_author/contracts/stub_1/contract.yaml b/tests/data/packages/default_author/contracts/stub_1/contract.yaml index 4d18afb131..09361eb0bc 100644 --- a/tests/data/packages/default_author/contracts/stub_1/contract.yaml +++ b/tests/data/packages/default_author/contracts/stub_1/contract.yaml @@ -7,7 +7,7 @@ license: Apache-2.0 aea_version: '>=1.0.0, <2.0.0' fingerprint: __init__.py: bafybeiajra74lxu4xlg4qcvqlhj7yndibsorbu24zgqgv7p3s2arjdhsdu - contract.py: bafybeig4v5lt7ln6r3dyyf6v3hak5gnvzfzdh4bdkuter3b4526lwxcnzm + contract.py: bafybeihxbf5fw25u6kqis446cbkptg7pj2n5o7xfmrbcnunttywyktknj4 fingerprint_ignore_patterns: [] class_name: MyScaffoldContract contract_interface_paths: {} diff --git a/tests/data/packages/hashes.csv b/tests/data/packages/hashes.csv index a3ec028f33..8fe90c6010 100644 --- a/tests/data/packages/hashes.csv +++ b/tests/data/packages/hashes.csv @@ -1,5 +1,5 @@ default_author/contracts/stub_0,bafybeidicpfgwqbr54v5pca77wu6ifnf23idf5htpdrudhbwxzaavm3wyy -default_author/contracts/stub_1,bafybeiamxbawlj3x5nq2qdolzfp65valyrhh55tszf733l3u5nxuvgkwhy +default_author/contracts/stub_1,bafybeibpmdrfhgz33ubww57rmmzn56g67e5xe462xiulk2p2ttezgujn5a fetchai/protocols/t_protocol,bafybeih4ciqba3x4b2yijkxurkqwiafixxy7jgghfkvtzmsxxuawq4rmvm fetchai/protocols/t_protocol_no_ct,bafybeibf4fp2loabpr334vko47o64dkbumso2gmpeylvk35yzkdbup4wti open_aea/connections/scaffold,bafybeifucsl5zfe4if4zfaddud77lzwgg7emv3mr3x3us57py7vbhktb24