1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-02-18 02:22:01 +00:00

tests/ui: embed images as base64 to diff.html

This commit is contained in:
Tomas Susanka 2020-01-03 13:49:35 +00:00
parent ce00fa667a
commit fe690a6b6b
2 changed files with 15 additions and 5 deletions

View File

@ -50,10 +50,12 @@ core unix device ui test:
- cd ../ci - cd ../ci
- pipenv run python prepare_ui_artifacts.py - pipenv run python prepare_ui_artifacts.py
artifacts: artifacts:
name: core-unix-device-test name: core-unix-device-ui-test
paths: paths:
- trezor.log - trezor.log
- ci/tmp/ - ci/tmp/
- tests/ui_tests/fixtures/*/diff.html
when: always
expire_in: 1 week expire_in: 1 week
core unix device test: core unix device test:

View File

@ -1,3 +1,4 @@
import base64
import filecmp import filecmp
from itertools import zip_longest 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 from . import download
def _image(src, fixture_test_path): def _image(src):
with td(): with td():
if src: 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: else:
i("missing") i("missing")
@ -50,8 +58,8 @@ def diff_file(fixture_test_path, test_name, actual_hash, expected_hash):
else: else:
background = "red" background = "red"
with tr(bgcolor=background): with tr(bgcolor=background):
_image(r, fixture_test_path) _image(r)
_image(a, fixture_test_path) _image(a)
with open(fixture_test_path / "diff.html", "w") as f: with open(fixture_test_path / "diff.html", "w") as f:
f.write(doc.render()) f.write(doc.render())