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 bug when importing packages in the same directory of a file, but this isn't the root directory of the project #1024

Merged
merged 1 commit into from
Apr 12, 2023

Conversation

meevee98
Copy link
Contributor

Summary or solution description
The compiler would allow user module importing only if imported from the root module.
Changed to accept imports relative to the importer file folder as well.

How to Reproduce

from boa3_test.test_sc.import_test.FromImportTyping import EmptyList as RootImportedFunction
from package_with_import.Module import EmptyList as FileDirImportedFunction
@public
def call_imported_from_root() -> list:
a: List[Any] = RootImportedFunction()
return a
@public
def call_imported_from_file_dir() -> list:
a: List[Any] = FileDirImportedFunction()
return a

Tests

def test_from_import_user_module_from_root_and_file_directories(self):
path = self.get_contract_path('FromImportUserModuleFromRootAndFileDir.py')
self.compile_and_save(path, root_folder=self.get_dir_path(self.test_root_dir))
path, _ = self.get_deploy_file_paths(path)
runner = NeoTestRunner()
invokes = []
expected_results = []
invokes.append(runner.call_contract(path, 'call_imported_from_root'))
expected_results.append([])
invokes.append(runner.call_contract(path, 'call_imported_from_file_dir'))
expected_results.append([])
runner.execute()
self.assertEqual(VMState.HALT, runner.vm_state, msg=runner.error)
for x in range(len(invokes)):
self.assertEqual(expected_results[x], invokes[x].result)

Platform:

  • OS: Windows 10 x64
  • Python version: Python 3.7+

… a file, but this isn't the root directory of the project
@meevee98 meevee98 requested a review from melanke April 11, 2023 19:32
@meevee98 meevee98 self-assigned this Apr 11, 2023
@coveralls
Copy link
Collaborator

Coverage Status

Coverage: 90.941% (-0.05%) from 90.992% when pulling 5d91d7d on CU-864e946ub into ab71cd5 on development.

@melanke melanke removed their request for review April 12, 2023 14:05
@luc10921 luc10921 merged commit f2e861c into development Apr 12, 2023
@melanke melanke deleted the CU-864e946ub branch May 5, 2023 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants