Commit 1a7f471a authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

* tests/python/ Ignore matplotlib font cache messages.

parent 94eca2ca
......@@ -180,21 +180,41 @@ def canonical_dict(dict, ignores):
return dict
def keep_dict(dict):
# pandas imports Matplotlib, which can display a message about building the
# the font cache if it does not exist, and if doing so takes more than 5
# seconds. Just ignore those.
if ('name' in dict and dict['name'] == 'stderr' and
type(dict['text']) is str and
dict['text'].startswith("Matplotlib is building the font cache")):
return False
return True
def compare_outputs(ref, test, ignores=[]):
'''Check that two lists of outputs are equivalent and report the
cref = [canonical_dict(d, ignores) for d in ref if keep_dict(d)]
ctest = [canonical_dict(d, ignores) for d in test if keep_dict(d)]
ok = True
if len(cref) != len(ctest):
print("output length mismatch (expected {}, got {})".format(
len(cref), len(ctest)))
ok = False
# There can be several outputs. For instance wnen the cell both
# prints a result (goes to "stdout") and displays an automaton
# (goes to "data").
exp = pprint.pformat([canonical_dict(d, ignores) for d in ref], width=132)
eff = pprint.pformat([canonical_dict(d, ignores) for d in test], width=132)
exp = pprint.pformat(cref, width=132)
eff = pprint.pformat(ctest, width=132)
if exp[:-1] != '\n':
exp += '\n'
if eff[:-1] != '\n':
eff += '\n'
if exp == eff:
return True
return ok
print(''.join(diff(exp.splitlines(1), eff.splitlines(1),
fromfile='expected', tofile='effective')))
......@@ -296,10 +316,6 @@ def test_notebook(ipynb):
failed = False
if len(outs) != len(cell.outputs):
print("output length mismatch (expected {}, got {})".format(
len(cell.outputs), len(outs)))
failed = True
if not compare_outputs(cell.outputs, outs):
failed = True
print("cell %d: " % i, end="")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment