python: More fixes for GraphViz variations

One of our ArchLinux build produice slightly different SVG.

* wrap/python/tests/ipnbdoctest.py: Strip larger parts of SVG outputs.
This commit is contained in:
Alexandre Duret-Lutz 2015-03-16 16:03:50 +01:00
parent 3c38780d50
commit 1f7c374798

View file

@ -70,10 +70,13 @@ def sanitize(s):
# SVG generated by graphviz may put note at different positions # SVG generated by graphviz may put note at different positions
# depending on the graphviz build. Let's just strip anything that # depending on the graphviz build. Let's just strip anything that
# look like a position. # look like a position.
s = re.sub(r'<path d="[^"]*"', '<path', s) s = re.sub(r'<path[^/]* d="[^"]*"', '<path', s)
s = re.sub(r'x="[0-9.]+"', 'x=""', s) s = re.sub(r'points="[^"]*"', 'points=""', s)
s = re.sub(r'y="[0-9.]+"', 'y=""', s) s = re.sub(r'x="[0-9.-]+"', 'x=""', s)
s = re.sub(r'y="[0-9.-]+"', 'y=""', s)
s = re.sub(r'width="[0-9.]+pt"', 'width=""', s)
s = re.sub(r'height="[0-9.]+pt"', 'height=""', s)
s = re.sub(r'viewBox="[0-9 .-]*"', 'viewbox=""', s)
return s return s
@ -102,17 +105,18 @@ def compare_outputs(test, ref, skip_cmp=('png', 'traceback',
if key not in test: if key not in test:
print("missing key: %s != %s" % (test.keys(), ref.keys())) print("missing key: %s != %s" % (test.keys(), ref.keys()))
return False return False
elif key not in skip_cmp and sanitize(test[key]) != sanitize(ref[key]): elif key not in skip_cmp:
print("mismatch %s:" % key) exp = sanitize(ref[key])
exp = ref[key] eff = sanitize(test[key])
eff = test[key] if exp != eff:
if exp[:-1] != '\n': print("mismatch %s:" % key)
exp += '\n' if exp[:-1] != '\n':
if eff[:-1] != '\n': exp += '\n'
eff += '\n' if eff[:-1] != '\n':
print(''.join(diff(exp.splitlines(1), eff.splitlines(1), eff += '\n'
fromfile='expected', tofile='effective'))) print(''.join(diff(exp.splitlines(1), eff.splitlines(1),
return False fromfile='expected', tofile='effective')))
return False
return True return True
def _wait_for_ready_backport(kc): def _wait_for_ready_backport(kc):