mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-26 00:08:10 +00:00
tests/ui: embed images as base64 to diff.html
This commit is contained in:
parent
ce00fa667a
commit
fe690a6b6b
@ -50,10 +50,12 @@ core unix device ui test:
|
||||
- cd ../ci
|
||||
- pipenv run python prepare_ui_artifacts.py
|
||||
artifacts:
|
||||
name: core-unix-device-test
|
||||
name: core-unix-device-ui-test
|
||||
paths:
|
||||
- trezor.log
|
||||
- ci/tmp/
|
||||
- tests/ui_tests/fixtures/*/diff.html
|
||||
when: always
|
||||
expire_in: 1 week
|
||||
|
||||
core unix device test:
|
||||
|
@ -1,3 +1,4 @@
|
||||
import base64
|
||||
import filecmp
|
||||
from itertools import zip_longest
|
||||
|
||||
@ -7,10 +8,17 @@ from dominate.tags import div, h1, hr, i, img, p, table, td, th, tr
|
||||
from . import download
|
||||
|
||||
|
||||
def _image(src, fixture_test_path):
|
||||
def _image(src):
|
||||
with td():
|
||||
if src:
|
||||
img(src=src.relative_to(fixture_test_path))
|
||||
# open image file
|
||||
image = open(src, "rb")
|
||||
# encode image as base64
|
||||
image = base64.b64encode(image.read())
|
||||
# convert output to str
|
||||
image = image.decode()
|
||||
# img(src=src.relative_to(fixture_test_path))
|
||||
img(src="data:image/png;base64, " + image)
|
||||
else:
|
||||
i("missing")
|
||||
|
||||
@ -50,8 +58,8 @@ def diff_file(fixture_test_path, test_name, actual_hash, expected_hash):
|
||||
else:
|
||||
background = "red"
|
||||
with tr(bgcolor=background):
|
||||
_image(r, fixture_test_path)
|
||||
_image(a, fixture_test_path)
|
||||
_image(r)
|
||||
_image(a)
|
||||
|
||||
with open(fixture_test_path / "diff.html", "w") as f:
|
||||
f.write(doc.render())
|
||||
|
Loading…
Reference in New Issue
Block a user