Skip to content

Commit

Permalink
Use absolute path for blessing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kobzol committed Nov 3, 2020
1 parent ceea096 commit e5efa4f
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions tests/updatetests.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import click
from conftest import DATA_DIR
import base64
import glob
import os
from pathlib import Path
import subprocess
import tempfile
import glob
import base64
from pathlib import Path

import click

from conftest import DATA_DIR

CHECKS = os.path.join(DATA_DIR, "checks")

Expand All @@ -21,7 +22,8 @@ def get_png(filename):
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
with open("tmp.png", "rb") as f:
png_data = f.read()
return "<img width=500 style=\"border: solid 1px black\" src=\"data:image/png;base64,{}\" />\n".format(base64.b64encode(png_data).decode())
return "<img width=500 style=\"border: solid 1px black\" src=\"data:image/png;base64,{}\" />\n".format(
base64.b64encode(png_data).decode())


def do_report(differences, test_svg_paths):
Expand All @@ -41,7 +43,8 @@ def do_report(differences, test_svg_paths):
os.chdir(tmpdir)
for i, name in enumerate(sorted(differences)):
print("{}/{}".format(i, len(differences)))
out.append("<tr><td>{}/{}</td><td>{}<td></tr>".format(i+1, len(differences), name))
out.append(
"<tr><td>{}/{}</td><td>{}<td></tr>".format(i + 1, len(differences), name))

out.append("<tr>")
check_name = os.path.join(CHECKS, name)
Expand Down Expand Up @@ -84,8 +87,10 @@ def run_update(differences, test_svg_paths):
@click.argument("testpath")
@click.option("--do-update/--do-not-update", default=False)
def test_path(testpath, do_update):
testpath = os.path.abspath(testpath)
check_names = set(path.name for path in Path(CHECKS).rglob('*.svg'))
test_svg_paths = {os.path.basename(path): path for path in glob.glob(os.path.join(testpath, '**/*.svg'))}
test_svg_paths = {os.path.basename(path): path for path in
glob.glob(os.path.join(testpath, '**/*.svg'))}
test_names = set(test_svg_paths.keys())

differences = check_names.intersection(test_names)
Expand Down

0 comments on commit e5efa4f

Please sign in to comment.