From fe690a6b6bccce752f6a12d85730754310c05928 Mon Sep 17 00:00:00 2001 From: Tomas Susanka Date: Fri, 3 Jan 2020 13:49:35 +0000 Subject: [PATCH] tests/ui: embed images as base64 to diff.html --- ci/test.yml | 4 +++- tests/ui_tests/html.py | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ci/test.yml b/ci/test.yml index 3de43bcba2..e00485892e 100644 --- a/ci/test.yml +++ b/ci/test.yml @@ -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: diff --git a/tests/ui_tests/html.py b/tests/ui_tests/html.py index adc2f75f41..29d39eab37 100644 --- a/tests/ui_tests/html.py +++ b/tests/ui_tests/html.py @@ -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())