Skip to content
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
5 changes: 2 additions & 3 deletions pandas/tests/plotting/test_datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,14 +519,14 @@ 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()
ts[5:25] = np.nan
_, ax = self.plt.subplots()
ts.plot(ax=ax)
lines = ax.get_lines()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, we occasionally do this. if its actually important then could split into 2 tests. not a big deal here.

tm._skip_if_mpl_1_5()
assert len(lines) == 1
l = lines[0]
data = l.get_xydata()
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down
14 changes: 14 additions & 0 deletions pandas/util/_test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def test_foo():
"""

import pytest
from distutils.version import LooseVersion


def safe_import(mod_name, min_version=None):
Expand Down Expand Up @@ -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")