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,10 +105,11 @@ 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:
exp = sanitize(ref[key])
eff = sanitize(test[key])
if exp != eff:
print("mismatch %s:" % key) print("mismatch %s:" % key)
exp = ref[key]
eff = test[key]
if exp[:-1] != '\n': if exp[:-1] != '\n':
exp += '\n' exp += '\n'
if eff[:-1] != '\n': if eff[:-1] != '\n':