From 3e38b0c2e1256d7a4e22b2b2c0f2599bbb4f3f07 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Mon, 4 Dec 2017 15:21:10 -0500 Subject: [PATCH] Added mpl_15 decorator --- pandas/tests/plotting/test_datetimelike.py | 5 ++--- pandas/util/_test_decorators.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/pandas/tests/plotting/test_datetimelike.py b/pandas/tests/plotting/test_datetimelike.py index db0c1e1cc563c..e87c67a682d46 100644 --- a/pandas/tests/plotting/test_datetimelike.py +++ b/pandas/tests/plotting/test_datetimelike.py @@ -519,6 +519,7 @@ def test_finder_hourly(self): xp = Period('1/1/1999', freq='H').ordinal assert rs == xp + @td.skip_if_mpl_1_5 @pytest.mark.slow def test_gaps(self): ts = tm.makeTimeSeries() @@ -526,7 +527,6 @@ def test_gaps(self): _, ax = self.plt.subplots() ts.plot(ax=ax) lines = ax.get_lines() - tm._skip_if_mpl_1_5() assert len(lines) == 1 l = lines[0] data = l.get_xydata() @@ -564,6 +564,7 @@ def test_gaps(self): mask = data.mask assert mask[2:5, 1].all() + @td.skip_if_mpl_1_5 @pytest.mark.slow def test_gap_upsample(self): low = tm.makeTimeSeries() @@ -580,8 +581,6 @@ def test_gap_upsample(self): l = lines[0] data = l.get_xydata() - tm._skip_if_mpl_1_5() - assert isinstance(data, np.ma.core.MaskedArray) mask = data.mask assert mask[5:25, 1].all() diff --git a/pandas/util/_test_decorators.py b/pandas/util/_test_decorators.py index b592a73e5d758..ab37c71404ad9 100644 --- a/pandas/util/_test_decorators.py +++ b/pandas/util/_test_decorators.py @@ -25,6 +25,7 @@ def test_foo(): """ import pytest +from distutils.version import LooseVersion def safe_import(mod_name, min_version=None): @@ -67,5 +68,18 @@ def _skip_if_no_mpl(): return True +def _skip_if_mpl_1_5(): + mod = safe_import("matplotlib") + + if mod: + v = mod.__version__ + if LooseVersion(v) > LooseVersion('1.4.3') or str(v)[0] == '0': + return True + else: + mod.use("Agg", warn=False) + + skip_if_no_mpl = pytest.mark.skipif(_skip_if_no_mpl(), reason="Missing matplotlib dependency") +skip_if_mpl_1_5 = pytest.mark.skipif(_skip_if_mpl_1_5(), + reason="matplotlib 1.5")