mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-27 07:40:59 +00:00
tests/ui_tests: use separate temporary directories for test cases
This commit is contained in:
parent
4bc865794f
commit
35a0ae1d18
@ -1,5 +1,6 @@
|
|||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
|
from contextlib import contextmanager
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import dominate
|
import dominate
|
||||||
@ -151,21 +152,24 @@ def create_dirs():
|
|||||||
def create_reports():
|
def create_reports():
|
||||||
removed_tests, added_tests, diff_tests = get_diff()
|
removed_tests, added_tests, diff_tests = get_diff()
|
||||||
|
|
||||||
with tempfile.TemporaryDirectory(prefix="trezor-records-") as temp_dir:
|
@contextmanager
|
||||||
temp_dir = Path(temp_dir)
|
def tmpdir():
|
||||||
|
with tempfile.TemporaryDirectory(prefix="trezor-records-") as temp_dir:
|
||||||
|
yield Path(temp_dir)
|
||||||
|
|
||||||
for test_name, test_hash in removed_tests.items():
|
for test_name, test_hash in removed_tests.items():
|
||||||
|
with tmpdir() as temp_dir:
|
||||||
download.fetch_recorded(test_hash, temp_dir)
|
download.fetch_recorded(test_hash, temp_dir)
|
||||||
removed(temp_dir, test_name)
|
removed(temp_dir, test_name)
|
||||||
|
|
||||||
for test_name, test_hash in added_tests.items():
|
for test_name, test_hash in added_tests.items():
|
||||||
path = RECORDED_SCREENS_PATH / test_name / "actual"
|
path = RECORDED_SCREENS_PATH / test_name / "actual"
|
||||||
if not path.exists():
|
if not path.exists():
|
||||||
raise RuntimeError("Folder does not exist, has it been recorded?", path)
|
raise RuntimeError("Folder does not exist, has it been recorded?", path)
|
||||||
added(path, test_name)
|
added(path, test_name)
|
||||||
|
|
||||||
for test_name, (master_hash, current_hash) in diff_tests.items():
|
for test_name, (master_hash, current_hash) in diff_tests.items():
|
||||||
master_screens = temp_dir
|
with tmpdir() as master_screens:
|
||||||
download.fetch_recorded(master_hash, master_screens)
|
download.fetch_recorded(master_hash, master_screens)
|
||||||
|
|
||||||
current_screens = RECORDED_SCREENS_PATH / test_name / "actual"
|
current_screens = RECORDED_SCREENS_PATH / test_name / "actual"
|
||||||
|
Loading…
Reference in New Issue
Block a user