Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fixes for Windows test failures on appveyor #5922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Feb 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ test_script:
# Now build the thing..
- '%CMD_IN_ENV% python setup.py develop'
# tests
# for now, just let them pass to get the after_test parts...
- python tests.py || cmd /c "exit /b 0"
- python tests.py
- python visual_tests.py

after_test:
# After the tests were a success, build packages (wheels and conda)
Expand Down Expand Up @@ -126,6 +126,7 @@ artifacts:
type: zip

on_failure:
- python visual_tests.py
- echo zipping images after a failure...
- 7z a result_images.zip result_images\ >NUL:
- 7z a result_images.zip result_images\ |grep -v "Compressing"
- appveyor PushArtifact result_images.zip
9 changes: 7 additions & 2 deletions lib/matplotlib/backends/backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -1530,8 +1530,13 @@ def gs_distill(tmpfile, eps=False, ptype='letter', bbox=None, rotated=False):

with io.open(outfile, 'rb') as fh:
if exit_status:
raise RuntimeError('ghostscript was not able to process \
your image.\nHere is the full report generated by ghostscript:\n\n' + fh.read())
output = fh.read()
m = "\n".join(["ghostscript was not able to process your image.",
"Here is the full report generated by ghostscript:",
"",
"%s"])
# use % to prevent problems with bytes
raise RuntimeError(m % output)
else:
verbose.report(fh.read(), 'debug')
os.remove(outfile)
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/dviread.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,8 +961,8 @@ def find_tex_file(filename, format=None):
`--format` option.

Apparently most existing TeX distributions on Unix-like systems
use kpathsea. I hear MikTeX (a popular distribution on Windows)
doesn't use kpathsea, so what do we do? (TODO)
use kpathsea. It's also available as part of MikTeX, a popular
distribution on Windows.

.. seealso::

Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/testing/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ def convert(filename, cache):
"""
base, extension = filename.rsplit('.', 1)
if extension not in converter:
raise ImageComparisonFailure(
"Don't know how to convert %s files to png" % extension)
from nose import SkipTest
raise SkipTest("Don't know how to convert %s files to png" % extension)
newname = base + '_' + extension + '.png'
if not os.path.exists(filename):
raise IOError("'%s' does not exist" % filename)
Expand Down
21 changes: 21 additions & 0 deletions lib/matplotlib/testing/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,3 +426,24 @@ def backend_switcher(*args, **kwargs):

return nose.tools.make_decorator(func)(backend_switcher)
return switch_backend_decorator


def skip_if_command_unavailable(cmd):
"""
skips a test if a command is unavailable.

Parameters
----------
cmd : list of str
must be a complete command which should not
return a non zero exit code, something like
["latex", "-version"]
"""
from matplotlib.compat.subprocess import check_output
try:
check_output(cmd)
except:
from nose import SkipTest
raise SkipTest('missing command: %s' % cmd[0])

return lambda f: f
12 changes: 9 additions & 3 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
import warnings
from matplotlib.cbook import IgnoredKeywordWarning

import sys
on_win = (sys.platform == 'win32')

# Note: Some test cases are run twice: once normally and once with labeled data
# These two must be defined in the same test function or need to have
# different baseline images to prevent race conditions when nose runs
Expand Down Expand Up @@ -2749,7 +2752,8 @@ def test_subplot_key_hash():

@image_comparison(baseline_images=['specgram_freqs',
'specgram_freqs_linear'],
remove_text=True, extensions=['png'], tol=0.03)
remove_text=True, extensions=['png'],
tol=0.05 if on_win else 0.03)
def test_specgram_freqs():
'''test axes.specgram in default (psd) mode with sinusoidal stimuli'''
n = 10000
Expand Down Expand Up @@ -2849,7 +2853,8 @@ def test_specgram_noise():

@image_comparison(baseline_images=['specgram_magnitude_freqs',
'specgram_magnitude_freqs_linear'],
remove_text=True, extensions=['png'], tol=0.03)
remove_text=True, extensions=['png'],
tol=0.05 if on_win else 0.03)
def test_specgram_magnitude_freqs():
'''test axes.specgram in magnitude mode with sinusoidal stimuli'''
n = 10000
Expand Down Expand Up @@ -2950,7 +2955,8 @@ def test_specgram_magnitude_noise():


@image_comparison(baseline_images=['specgram_angle_freqs'],
remove_text=True, extensions=['png'])
remove_text=True, extensions=['png'],
tol=0.003 if on_win else 0)
def test_specgram_angle_freqs():
'''test axes.specgram in angle mode with sinusoidal stimuli'''
n = 10000
Expand Down
2 changes: 2 additions & 0 deletions lib/matplotlib/tests/test_backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def test_savefig_to_stringio_with_distiller():

@cleanup
@needs_tex
@needs_ghostscript
def test_savefig_to_stringio_with_usetex():
matplotlib.rcParams['text.latex.unicode'] = True
matplotlib.rcParams['text.usetex'] = True
Expand All @@ -90,6 +91,7 @@ def test_savefig_to_stringio_eps_afm():

@cleanup
@needs_tex
@needs_ghostscript
def test_savefig_to_stringio_with_usetex_eps():
matplotlib.rcParams['text.latex.unicode'] = True
matplotlib.rcParams['text.usetex'] = True
Expand Down
3 changes: 3 additions & 0 deletions lib/matplotlib/tests/test_dviread.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
unicode_literals)

from matplotlib.externals import six
from matplotlib.testing.decorators import skip_if_command_unavailable


from nose.tools import assert_equal, with_setup
import matplotlib.dviread as dr
Expand Down Expand Up @@ -60,6 +62,7 @@ def test_PsfontsMap():
assert_equal(entry.filename, '/absolute/font9.pfb')


@skip_if_command_unavailable(["kpsewhich", "-version"])
def test_dviread():
dir = os.path.join(os.path.dirname(__file__), 'baseline_images', 'dviread')
with open(os.path.join(dir, 'test.json')) as f:
Expand Down
5 changes: 4 additions & 1 deletion lib/matplotlib/tests/test_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
from matplotlib import path as mpath
from matplotlib import transforms as mtrans

import sys
on_win = (sys.platform == 'win32')


def test_Polygon_close():
#: Github issue #1018 identified a bug in the Polygon handling
Expand Down Expand Up @@ -250,7 +253,7 @@ def test_wedge_movement():


@image_comparison(baseline_images=['wedge_range'],
remove_text=True)
remove_text=True, tol=0.06 if on_win else 0)
def test_wedge_range():
ax = plt.axes()

Expand Down
5 changes: 4 additions & 1 deletion lib/matplotlib/tests/test_patheffects.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
import mock
from nose.tools import assert_equal

import sys
on_win = (sys.platform == 'win32')


@image_comparison(baseline_images=['patheffect1'], remove_text=True)
def test_patheffect1():
Expand Down Expand Up @@ -110,7 +113,7 @@ def test_SimplePatchShadow_offset():
assert_equal(pe._offset, (4, 5))


@image_comparison(baseline_images=['collection'])
@image_comparison(baseline_images=['collection'], tol=0.013 if on_win else 0)
def test_collection():
x, y = np.meshgrid(np.linspace(0, 10, 150), np.linspace(-5, 5, 100))
data = np.sin(x) + np.cos(y)
Expand Down
5 changes: 4 additions & 1 deletion lib/matplotlib/tests/test_triangulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import matplotlib.cm as cm
from matplotlib.path import Path

import sys
on_win = (sys.platform == 'win32')

def test_delaunay():
# No duplicate points, regular grid.
Expand Down Expand Up @@ -770,7 +772,8 @@ def z(x, y):


@image_comparison(baseline_images=['tri_smooth_gradient'],
extensions=['png'], remove_text=True)
extensions=['png'], remove_text=True,
tol=0.015 if on_win else 0)
def test_tri_smooth_gradient():
# Image comparison based on example trigradient_demo.

Expand Down
Loading