diff --git a/ci/prepare_ui_artifacts.py b/ci/prepare_ui_artifacts.py index 764ddb179..9f290c304 100644 --- a/ci/prepare_ui_artifacts.py +++ b/ci/prepare_ui_artifacts.py @@ -2,7 +2,7 @@ import shutil import sys from pathlib import Path -ROOT = Path(__file__).parent / ".." +ROOT = Path(__file__).resolve().parent.parent sys.path.insert(0, str(ROOT)) # Needed for setup purposes, filling the FILE_HASHES dict from tests.ui_tests import read_fixtures # isort:skip @@ -16,4 +16,6 @@ for test_case in FILE_HASHES.keys(): expected_hash = FILE_HASHES[test_case] actual_hash = _hash_files(recorded_dir) assert expected_hash == actual_hash - shutil.make_archive(ROOT / "ci/ui_test_records" / actual_hash, "zip", recorded_dir) + shutil.make_archive( + str(ROOT / "ci/ui_test_records" / actual_hash), "zip", recorded_dir + ) diff --git a/common/tools/coin_info.py b/common/tools/coin_info.py index 48cef357a..8f4e29eaa 100755 --- a/common/tools/coin_info.py +++ b/common/tools/coin_info.py @@ -13,7 +13,7 @@ except ImportError: log = logging.getLogger(__name__) -ROOT = (Path(__file__).parent / "..").resolve() +ROOT = Path(__file__).resolve().parent.parent if os.environ.get("DEFS_DIR"): DEFS_DIR = Path(os.environ.get("DEFS_DIR")).resolve() diff --git a/core/emu.py b/core/emu.py index 5f089bc00..85b89507a 100755 --- a/core/emu.py +++ b/core/emu.py @@ -21,7 +21,7 @@ except Exception: inotify = None -HERE = Path(__file__).parent.resolve() +HERE = Path(__file__).resolve().parent MICROPYTHON = HERE / "build" / "unix" / "trezor-emu-core" SRC_DIR = HERE / "src" diff --git a/core/tools/alloc.py b/core/tools/alloc.py index daade603d..6a7aafc77 100755 --- a/core/tools/alloc.py +++ b/core/tools/alloc.py @@ -4,7 +4,7 @@ from pathlib import Path from types import SimpleNamespace import click -HERE = Path(__file__).parent.resolve() +HERE = Path(__file__).resolve().parent def parse_alloc_data(alloc_data): diff --git a/core/tools/build_icons.py b/core/tools/build_icons.py index f8311356b..15c0fc635 100755 --- a/core/tools/build_icons.py +++ b/core/tools/build_icons.py @@ -8,7 +8,7 @@ from PIL import Image from trezorlib import toif -HERE = Path(__file__).parent.resolve() +HERE = Path(__file__).resolve().parent ROOT = HERE.parent.parent ICON_SIZE = (64, 64) diff --git a/core/tools/build_mocks b/core/tools/build_mocks index 3e7fd914a..9d5867fb5 100755 --- a/core/tools/build_mocks +++ b/core/tools/build_mocks @@ -1,14 +1,12 @@ #!/usr/bin/env python3 -import glob import os -import re import shutil import subprocess import sys import tempfile from pathlib import Path -CORE_DIR = Path(__file__).parent.parent.resolve() +CORE_DIR = Path(__file__).resolve().parent.parent EXTMOD_PATH = CORE_DIR / "embed" / "extmod" MOCKS_PATH = CORE_DIR / "mocks" / "generated" @@ -133,6 +131,7 @@ def do_generate(): shutil.rmtree(MOCKS_PATH) build_directory(MOCKS_PATH) + if __name__ == "__main__": if len(sys.argv) > 1 and sys.argv[1] == "--check": do_check() diff --git a/tests/common.py b/tests/common.py index 745d45f79..a300b7171 100644 --- a/tests/common.py +++ b/tests/common.py @@ -52,7 +52,7 @@ EXTERNAL_ENTROPY = b"zlutoucky kun upel divoke ody" * 2 TEST_ADDRESS_N = tools.parse_path("m/44h/1h/0h/0/0") COMMON_FIXTURES_DIR = ( - Path(__file__).parent.resolve().parent / "common" / "tests" / "fixtures" + Path(__file__).resolve().parent.parent / "common" / "tests" / "fixtures" ) diff --git a/tests/emulators.py b/tests/emulators.py index 6dcaeb624..bdadaa08c 100644 --- a/tests/emulators.py +++ b/tests/emulators.py @@ -20,7 +20,7 @@ from pathlib import Path from trezorlib._internal.emulator import CoreEmulator, LegacyEmulator -ROOT = Path(__file__).parent.parent.resolve() +ROOT = Path(__file__).resolve().parent.parent BINDIR = ROOT / "tests" / "emulators" LOCAL_BUILD_PATHS = { diff --git a/tests/show_results.py b/tests/show_results.py index 1b60b58fd..832ff298f 100755 --- a/tests/show_results.py +++ b/tests/show_results.py @@ -11,7 +11,7 @@ from pathlib import Path import click -ROOT = Path(__file__).parent.parent.resolve() +ROOT = Path(__file__).resolve().parent.parent TEST_RESULT_PATH = ROOT / "tests" / "ui_tests" / "reporting" / "reports" / "test" diff --git a/tests/tx_cache.py b/tests/tx_cache.py index f43a05b82..b7517ea31 100755 --- a/tests/tx_cache.py +++ b/tests/tx_cache.py @@ -25,9 +25,9 @@ import requests from trezorlib import btc, messages, protobuf -REPOSITORY_ROOT = Path(__file__).parent.parent +REPOSITORY_ROOT = Path(__file__).resolve().parent.parent TOOLS_PATH = REPOSITORY_ROOT / "common" / "tools" -CACHE_PATH = Path(__file__).parent / "txcache" +CACHE_PATH = Path(__file__).resolve().parent / "txcache" sys.path.insert(0, str(TOOLS_PATH)) from coin_info import coin_info # isort:skip diff --git a/tests/ui_tests/__init__.py b/tests/ui_tests/__init__.py index db3eb175a..03aa9562d 100644 --- a/tests/ui_tests/__init__.py +++ b/tests/ui_tests/__init__.py @@ -11,7 +11,7 @@ from PIL import Image from .reporting import testreport -UI_TESTS_DIR = Path(__file__).parent.resolve() +UI_TESTS_DIR = Path(__file__).resolve().parent SCREENS_DIR = UI_TESTS_DIR / "screens" HASH_FILE = UI_TESTS_DIR / "fixtures.json" SUGGESTION_FILE = UI_TESTS_DIR / "fixtures.suggestion.json" diff --git a/tests/ui_tests/reporting/download.py b/tests/ui_tests/reporting/download.py index f78902c50..e432d6140 100644 --- a/tests/ui_tests/reporting/download.py +++ b/tests/ui_tests/reporting/download.py @@ -1,15 +1,15 @@ import json -import pathlib import urllib.error import urllib.request import zipfile +from pathlib import Path from typing import Dict import requests RECORDS_WEBSITE = "https://firmware.corp.sldev.cz/ui_tests/" FIXTURES_MASTER = "https://raw.githubusercontent.com/trezor/trezor-firmware/master/tests/ui_tests/fixtures.json" -FIXTURES_CURRENT = pathlib.Path(__file__).parent / "../fixtures.json" +FIXTURES_CURRENT = Path(__file__).resolve().parent.parent / "fixtures.json" _dns_failed = False diff --git a/tests/ui_tests/reporting/report_master_diff.py b/tests/ui_tests/reporting/report_master_diff.py index b79265fe0..4f3ec9c01 100644 --- a/tests/ui_tests/reporting/report_master_diff.py +++ b/tests/ui_tests/reporting/report_master_diff.py @@ -10,8 +10,8 @@ from dominate.tags import br, h1, h2, hr, i, p, table, td, th, tr import download # isort:skip import html # isort:skip -REPORTS_PATH = Path(__file__).parent.resolve() / "reports" / "master_diff" -RECORDED_SCREENS_PATH = Path(__file__).parent.parent.resolve() / "screens" +REPORTS_PATH = Path(__file__).resolve().parent / "reports" / "master_diff" +RECORDED_SCREENS_PATH = Path(__file__).resolve().parent.parent / "screens" def get_diff(): diff --git a/tests/ui_tests/reporting/testreport.py b/tests/ui_tests/reporting/testreport.py index a3b6b24ea..36f912557 100644 --- a/tests/ui_tests/reporting/testreport.py +++ b/tests/ui_tests/reporting/testreport.py @@ -10,7 +10,7 @@ from dominate.util import text from . import download, html -HERE = Path(__file__).parent.resolve() +HERE = Path(__file__).resolve().parent REPORTS_PATH = HERE / "reports" / "test" STYLE = (HERE / "testreport.css").read_text()