fix import path

pull/1799/head
alpharush 2 years ago
parent 8fcedceb3f
commit b54574ed08
  1. 13
      tests/e2e/detectors/test_detectors.py

@ -7,7 +7,8 @@ from typing import Type, Optional, List
import pytest import pytest
from deepdiff import DeepDiff # pip install deepdiff from deepdiff import DeepDiff # pip install deepdiff
from crytic_compile import CryticCompile, save_to_zip, load_from_zip from crytic_compile import CryticCompile, save_to_zip
from crytic_compile.utils.zip import load_from_zip
from solc_select.solc_select import install_artifacts as install_solc_versions from solc_select.solc_select import install_artifacts as install_solc_versions
@ -1670,7 +1671,9 @@ def test_detector(test_item: Test):
test_item.solc_ver, test_item.solc_ver,
) )
test_file_path = pathlib.Path(test_dir_path, test_item.test_file).as_posix() test_file_path = pathlib.Path(test_dir_path, test_item.test_file).as_posix()
expected_result_path = pathlib.Path(test_dir_path, test_item.expected_result).absolute().as_posix() expected_result_path = (
pathlib.Path(test_dir_path, test_item.expected_result).absolute().as_posix()
)
cc = load_from_zip(f"{test_file_path}-{test_item.solc_ver}.zip")[0] cc = load_from_zip(f"{test_file_path}-{test_item.solc_ver}.zip")[0]
sl = Slither(cc) sl = Slither(cc)
@ -1717,7 +1720,9 @@ def _generate_test(test_item: Test, skip_existing=False):
test_item.solc_ver, test_item.solc_ver,
) )
test_file_path = pathlib.Path(test_dir_path, test_item.test_file).as_posix() test_file_path = pathlib.Path(test_dir_path, test_item.test_file).as_posix()
expected_result_path = pathlib.Path(test_dir_path, test_item.expected_result).absolute().as_posix() expected_result_path = (
pathlib.Path(test_dir_path, test_item.expected_result).absolute().as_posix()
)
if skip_existing: if skip_existing:
if os.path.isfile(expected_result_path): if os.path.isfile(expected_result_path):
@ -1741,6 +1746,7 @@ def _generate_test(test_item: Test, skip_existing=False):
with open(expected_result_path, "w", encoding="utf8") as f: with open(expected_result_path, "w", encoding="utf8") as f:
f.write(json.dumps(results, indent=4)) f.write(json.dumps(results, indent=4))
def _generate_compile(test_item: Test, skip_existing=False): def _generate_compile(test_item: Test, skip_existing=False):
test_dir_path = pathlib.Path( test_dir_path = pathlib.Path(
pathlib.Path().absolute(), pathlib.Path().absolute(),
@ -1762,6 +1768,7 @@ def _generate_compile(test_item: Test, skip_existing=False):
cc = CryticCompile(test_file) cc = CryticCompile(test_file)
save_to_zip([cc], zip_artifact_path) save_to_zip([cc], zip_artifact_path)
if __name__ == "__main__": if __name__ == "__main__":
if len(sys.argv) != 2: if len(sys.argv) != 2:
print("To generate the json artifacts run\n\tpython tests/test_detectors.py --generate") print("To generate the json artifacts run\n\tpython tests/test_detectors.py --generate")

Loading…
Cancel
Save