Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Spot
Spot
Commits
ff3a3f81
Commit
ff3a3f81
authored
Jul 27, 2020
by
Alexandre Duret-Lutz
Browse files
* tests/python/ipnbdoctest.py: Ignore matplotlib font cache messages.
parent
5ec9d55f
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/python/ipnbdoctest.py
View file @
ff3a3f81
...
...
@@ -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
(
c
test
,
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
=
""
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment