-
Notifications
You must be signed in to change notification settings - Fork 2
Refactor str paths to Path
#293
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
Conversation
| def load_input_json(test_dir: str) -> dict: | ||
| try: | ||
| with open(join(test_dir, INPUT_FILE_NAME)) as f: | ||
| return json.load(f) | ||
| except FileNotFoundError: | ||
| raise FileNotFoundError(f'{INPUT_FILE_NAME!r} not found in "{test_dir!r}"') from None | ||
|
|
||
|
|
||
| def find_test_wasm_path(test_dir: str) -> str: | ||
| test_wasm_path = glob.glob(test_dir + '/output/*.wasm') | ||
| # TODO this loads the first wasm file in the directory. what if there are multiple wasm files? | ||
| if test_wasm_path: | ||
| return test_wasm_path[0] | ||
| else: | ||
| raise ValueError(f'WASM file not found: {test_dir}/output/?.wasm') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add these functions to kasmer-multiversx in a follow-up PR.
tothtamas28
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice refactoring!
| abi_paths = glob.glob(test_dir + '/output/*.abi.json') | ||
| # TODO this loads the first wasm file in the directory. what if there are multiple wasm files? | ||
| def get_test_endpoints(test_dir: Path) -> Mapping[str, tuple[str, ...]]: | ||
| abi_paths = glob.glob(str(test_dir) + '/output/*.abi.json') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using Path.glob instead: https://docs.python.org/3/library/pathlib.html#pathlib.Path.glob
|
|
||
| code = get_contract_code(tx['contractCode'], filename) | ||
| assert isinstance(code, str) | ||
| assert isinstance(code, Path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| assert isinstance(code, Path) | |
| assert code is not None |
Co-authored-by: Tamás Tóth <tothtamas28@users.noreply.github.com>
Refactored the
scenarioandkasmermodules to usePathinstead ofstrfor variables representing file and directory paths.