1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-06-05 15:48:45 +00:00

chore(common): always use resolve() when accessing parent of the Path

[no changelog]
This commit is contained in:
grdddj 2022-01-28 16:02:17 +01:00 committed by matejcik
parent a3c79bf4f7
commit 5d76144ef5
14 changed files with 21 additions and 20 deletions

View File

@ -2,7 +2,7 @@ import shutil
import sys import sys
from pathlib import Path from pathlib import Path
ROOT = Path(__file__).parent / ".." ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(ROOT)) sys.path.insert(0, str(ROOT))
# Needed for setup purposes, filling the FILE_HASHES dict # Needed for setup purposes, filling the FILE_HASHES dict
from tests.ui_tests import read_fixtures # isort:skip 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] expected_hash = FILE_HASHES[test_case]
actual_hash = _hash_files(recorded_dir) actual_hash = _hash_files(recorded_dir)
assert expected_hash == actual_hash 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
)

View File

@ -13,7 +13,7 @@ except ImportError:
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
ROOT = (Path(__file__).parent / "..").resolve() ROOT = Path(__file__).resolve().parent.parent
if os.environ.get("DEFS_DIR"): if os.environ.get("DEFS_DIR"):
DEFS_DIR = Path(os.environ.get("DEFS_DIR")).resolve() DEFS_DIR = Path(os.environ.get("DEFS_DIR")).resolve()

View File

@ -21,7 +21,7 @@ except Exception:
inotify = None inotify = None
HERE = Path(__file__).parent.resolve() HERE = Path(__file__).resolve().parent
MICROPYTHON = HERE / "build" / "unix" / "trezor-emu-core" MICROPYTHON = HERE / "build" / "unix" / "trezor-emu-core"
SRC_DIR = HERE / "src" SRC_DIR = HERE / "src"

View File

@ -4,7 +4,7 @@ from pathlib import Path
from types import SimpleNamespace from types import SimpleNamespace
import click import click
HERE = Path(__file__).parent.resolve() HERE = Path(__file__).resolve().parent
def parse_alloc_data(alloc_data): def parse_alloc_data(alloc_data):

View File

@ -8,7 +8,7 @@ from PIL import Image
from trezorlib import toif from trezorlib import toif
HERE = Path(__file__).parent.resolve() HERE = Path(__file__).resolve().parent
ROOT = HERE.parent.parent ROOT = HERE.parent.parent
ICON_SIZE = (64, 64) ICON_SIZE = (64, 64)

View File

@ -1,14 +1,12 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import glob
import os import os
import re
import shutil import shutil
import subprocess import subprocess
import sys import sys
import tempfile import tempfile
from pathlib import Path from pathlib import Path
CORE_DIR = Path(__file__).parent.parent.resolve() CORE_DIR = Path(__file__).resolve().parent.parent
EXTMOD_PATH = CORE_DIR / "embed" / "extmod" EXTMOD_PATH = CORE_DIR / "embed" / "extmod"
MOCKS_PATH = CORE_DIR / "mocks" / "generated" MOCKS_PATH = CORE_DIR / "mocks" / "generated"
@ -133,6 +131,7 @@ def do_generate():
shutil.rmtree(MOCKS_PATH) shutil.rmtree(MOCKS_PATH)
build_directory(MOCKS_PATH) build_directory(MOCKS_PATH)
if __name__ == "__main__": if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1] == "--check": if len(sys.argv) > 1 and sys.argv[1] == "--check":
do_check() do_check()

View File

@ -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") TEST_ADDRESS_N = tools.parse_path("m/44h/1h/0h/0/0")
COMMON_FIXTURES_DIR = ( COMMON_FIXTURES_DIR = (
Path(__file__).parent.resolve().parent / "common" / "tests" / "fixtures" Path(__file__).resolve().parent.parent / "common" / "tests" / "fixtures"
) )

View File

@ -20,7 +20,7 @@ from pathlib import Path
from trezorlib._internal.emulator import CoreEmulator, LegacyEmulator from trezorlib._internal.emulator import CoreEmulator, LegacyEmulator
ROOT = Path(__file__).parent.parent.resolve() ROOT = Path(__file__).resolve().parent.parent
BINDIR = ROOT / "tests" / "emulators" BINDIR = ROOT / "tests" / "emulators"
LOCAL_BUILD_PATHS = { LOCAL_BUILD_PATHS = {

View File

@ -11,7 +11,7 @@ from pathlib import Path
import click import click
ROOT = Path(__file__).parent.parent.resolve() ROOT = Path(__file__).resolve().parent.parent
TEST_RESULT_PATH = ROOT / "tests" / "ui_tests" / "reporting" / "reports" / "test" TEST_RESULT_PATH = ROOT / "tests" / "ui_tests" / "reporting" / "reports" / "test"

View File

@ -25,9 +25,9 @@ import requests
from trezorlib import btc, messages, protobuf 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" 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)) sys.path.insert(0, str(TOOLS_PATH))
from coin_info import coin_info # isort:skip from coin_info import coin_info # isort:skip

View File

@ -11,7 +11,7 @@ from PIL import Image
from .reporting import testreport from .reporting import testreport
UI_TESTS_DIR = Path(__file__).parent.resolve() UI_TESTS_DIR = Path(__file__).resolve().parent
SCREENS_DIR = UI_TESTS_DIR / "screens" SCREENS_DIR = UI_TESTS_DIR / "screens"
HASH_FILE = UI_TESTS_DIR / "fixtures.json" HASH_FILE = UI_TESTS_DIR / "fixtures.json"
SUGGESTION_FILE = UI_TESTS_DIR / "fixtures.suggestion.json" SUGGESTION_FILE = UI_TESTS_DIR / "fixtures.suggestion.json"

View File

@ -1,15 +1,15 @@
import json import json
import pathlib
import urllib.error import urllib.error
import urllib.request import urllib.request
import zipfile import zipfile
from pathlib import Path
from typing import Dict from typing import Dict
import requests import requests
RECORDS_WEBSITE = "https://firmware.corp.sldev.cz/ui_tests/" 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_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 _dns_failed = False

View File

@ -10,8 +10,8 @@ from dominate.tags import br, h1, h2, hr, i, p, table, td, th, tr
import download # isort:skip import download # isort:skip
import html # isort:skip import html # isort:skip
REPORTS_PATH = Path(__file__).parent.resolve() / "reports" / "master_diff" REPORTS_PATH = Path(__file__).resolve().parent / "reports" / "master_diff"
RECORDED_SCREENS_PATH = Path(__file__).parent.parent.resolve() / "screens" RECORDED_SCREENS_PATH = Path(__file__).resolve().parent.parent / "screens"
def get_diff(): def get_diff():

View File

@ -10,7 +10,7 @@ from dominate.util import text
from . import download, html from . import download, html
HERE = Path(__file__).parent.resolve() HERE = Path(__file__).resolve().parent
REPORTS_PATH = HERE / "reports" / "test" REPORTS_PATH = HERE / "reports" / "test"
STYLE = (HERE / "testreport.css").read_text() STYLE = (HERE / "testreport.css").read_text()