From: Sandro Tosi <morph@debian.org>
Date: Wed, 18 Jan 2017 20:05:24 -0500
Subject: Increase test tollerance

Patch taken from Fedora packaging:
http://pkgs.fedoraproject.org/cgit/rpms/python-matplotlib.git/plain/python-matplotlib-increase-tests-tolerance.patch
---
 lib/matplotlib/testing/decorators.py     | 2 +-
 lib/matplotlib/tests/test_mathtext.py    | 5 ++---
 lib/matplotlib/tests/test_patheffects.py | 2 +-
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/lib/matplotlib/testing/decorators.py b/lib/matplotlib/testing/decorators.py
index 0ce6e62..2692cb9 100644
--- a/lib/matplotlib/testing/decorators.py
+++ b/lib/matplotlib/testing/decorators.py
@@ -408,7 +408,7 @@ def _pytest_image_comparison(baseline_images, extensions, tol,
     return decorator
 
 
-def image_comparison(baseline_images, extensions=None, tol=0,
+def image_comparison(baseline_images, extensions=None, tol=0.306,
                      freetype_version=None, remove_text=False,
                      savefig_kwarg=None,
                      # Default of mpl_test_settings fixture and cleanup too.
diff --git a/lib/matplotlib/tests/test_mathtext.py b/lib/matplotlib/tests/test_mathtext.py
index cdc1093..f1aa386 100644
--- a/lib/matplotlib/tests/test_mathtext.py
+++ b/lib/matplotlib/tests/test_mathtext.py
@@ -161,7 +161,6 @@ for fonts, chars in font_test_specs:
     for set in chars:
         font_tests.append(wrapper % set)
 
-
 @pytest.fixture
 def baseline_images(request, fontset, index):
     return ['%s_%s_%02d' % (request.param, fontset, index)]
@@ -173,7 +172,7 @@ def baseline_images(request, fontset, index):
                          ['cm', 'stix', 'stixsans', 'dejavusans',
                           'dejavuserif'])
 @pytest.mark.parametrize('baseline_images', ['mathtext'], indirect=True)
-@image_comparison(baseline_images=None)
+@image_comparison(baseline_images=None, tol=0.310)
 def test_mathtext_rendering(baseline_images, fontset, index, test):
     matplotlib.rcParams['mathtext.fontset'] = fontset
     fig = plt.figure(figsize=(5.25, 0.75))
@@ -187,7 +186,7 @@ def test_mathtext_rendering(baseline_images, fontset, index, test):
                          ['cm', 'stix', 'stixsans', 'dejavusans',
                           'dejavuserif'])
 @pytest.mark.parametrize('baseline_images', ['mathfont'], indirect=True)
-@image_comparison(baseline_images=None, extensions=['png'])
+@image_comparison(baseline_images=None, extensions=['png'], tol=0.310)
 def test_mathfont_rendering(baseline_images, fontset, index, test):
     matplotlib.rcParams['mathtext.fontset'] = fontset
     fig = plt.figure(figsize=(5.25, 0.75))
diff --git a/lib/matplotlib/tests/test_patheffects.py b/lib/matplotlib/tests/test_patheffects.py
index fe72659..3e670fe 100644
--- a/lib/matplotlib/tests/test_patheffects.py
+++ b/lib/matplotlib/tests/test_patheffects.py
@@ -121,7 +121,7 @@ def test_SimplePatchShadow_offset():
     assert pe._offset == (4, 5)
 
 
-@image_comparison(baseline_images=['collection'], tol=0.02)
+@image_comparison(baseline_images=['collection'], tol=0.083)
 def test_collection():
     x, y = np.meshgrid(np.linspace(0, 10, 150), np.linspace(-5, 5, 100))
     data = np.sin(x) + np.cos(y)
