* tests/python/ipnbdoctest.py: Ignore matplotlib font cache messages.
This commit is contained in:
parent
5ec9d55fea
commit
ff3a3f8144
1 changed files with 23 additions and 7 deletions
|
|
@ -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
|
||||
result.'''
|
||||
|
||||
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
|
||||
else:
|
||||
print(''.join(diff(exp.splitlines(1), eff.splitlines(1),
|
||||
fromfile='expected', tofile='effective')))
|
||||
|
|
@ -296,10 +316,6 @@ def test_notebook(ipynb):
|
|||
continue
|
||||
|
||||
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="")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue