2020-12-22 02:02:28 +00:00
|
|
|
from pathlib import Path
|
|
|
|
from typing import Union
|
|
|
|
|
|
|
|
LIBSOLIDITY_TEST_DIR = Path(__file__).parent.parent / 'libsolidity'
|
|
|
|
FIXTURE_DIR = Path(__file__).parent / 'fixtures'
|
|
|
|
|
|
|
|
def load_file(path: Union[Path, str]) -> str:
|
2021-01-19 15:56:27 +00:00
|
|
|
# NOTE: newline='' disables newline conversion.
|
|
|
|
# We want the file exactly as is because changing even a single byte in the source affects metadata.
|
|
|
|
with open(path, 'r', encoding='utf-8', newline='') as f:
|
2020-12-22 02:02:28 +00:00
|
|
|
return f.read()
|
|
|
|
|
|
|
|
def load_fixture(relative_path: Union[Path, str]) -> str:
|
|
|
|
return load_file(FIXTURE_DIR / relative_path)
|
|
|
|
|
|
|
|
def load_libsolidity_test_case(relative_path: Union[Path, str]) -> str:
|
|
|
|
return load_file(LIBSOLIDITY_TEST_DIR / relative_path)
|