Skip to content

Commit f6e4292

Browse files
WillAydjreback
authored andcommitted
Added mpl_15 decorator (#18682)
1 parent 9ec7212 commit f6e4292

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

pandas/tests/plotting/test_datetimelike.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -519,14 +519,14 @@ def test_finder_hourly(self):
519519
xp = Period('1/1/1999', freq='H').ordinal
520520
assert rs == xp
521521

522+
@td.skip_if_mpl_1_5
522523
@pytest.mark.slow
523524
def test_gaps(self):
524525
ts = tm.makeTimeSeries()
525526
ts[5:25] = np.nan
526527
_, ax = self.plt.subplots()
527528
ts.plot(ax=ax)
528529
lines = ax.get_lines()
529-
tm._skip_if_mpl_1_5()
530530
assert len(lines) == 1
531531
l = lines[0]
532532
data = l.get_xydata()
@@ -564,6 +564,7 @@ def test_gaps(self):
564564
mask = data.mask
565565
assert mask[2:5, 1].all()
566566

567+
@td.skip_if_mpl_1_5
567568
@pytest.mark.slow
568569
def test_gap_upsample(self):
569570
low = tm.makeTimeSeries()
@@ -580,8 +581,6 @@ def test_gap_upsample(self):
580581
l = lines[0]
581582
data = l.get_xydata()
582583

583-
tm._skip_if_mpl_1_5()
584-
585584
assert isinstance(data, np.ma.core.MaskedArray)
586585
mask = data.mask
587586
assert mask[5:25, 1].all()

pandas/util/_test_decorators.py

+14
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def test_foo():
2525
"""
2626

2727
import pytest
28+
from distutils.version import LooseVersion
2829

2930

3031
def safe_import(mod_name, min_version=None):
@@ -67,5 +68,18 @@ def _skip_if_no_mpl():
6768
return True
6869

6970

71+
def _skip_if_mpl_1_5():
72+
mod = safe_import("matplotlib")
73+
74+
if mod:
75+
v = mod.__version__
76+
if LooseVersion(v) > LooseVersion('1.4.3') or str(v)[0] == '0':
77+
return True
78+
else:
79+
mod.use("Agg", warn=False)
80+
81+
7082
skip_if_no_mpl = pytest.mark.skipif(_skip_if_no_mpl(),
7183
reason="Missing matplotlib dependency")
84+
skip_if_mpl_1_5 = pytest.mark.skipif(_skip_if_mpl_1_5(),
85+
reason="matplotlib 1.5")

0 commit comments

Comments
 (0)