From 15e82baf4cbd62cfeb0bf4c05d51068386d52757 Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Wed, 7 Mar 2018 07:41:22 -0500 Subject: [PATCH] TST: xfail some tests for mpl 2.2 compat xref #20031 --- pandas/tests/plotting/test_datetimelike.py | 4 ++-- pandas/tests/plotting/test_frame.py | 1 + pandas/tests/plotting/test_misc.py | 1 + pandas/tests/plotting/test_series.py | 1 + pandas/util/_test_decorators.py | 13 +++++++++++++ 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/pandas/tests/plotting/test_datetimelike.py b/pandas/tests/plotting/test_datetimelike.py index 18eefa6a14a37..9b721e45099fe 100644 --- a/pandas/tests/plotting/test_datetimelike.py +++ b/pandas/tests/plotting/test_datetimelike.py @@ -1356,10 +1356,10 @@ def test_plot_outofbounds_datetime(self): values = [datetime(1677, 1, 1, 12), datetime(1677, 1, 2, 12)] ax.plot(values) + @td.xfail_if_mpl_2_2 @pytest.mark.skip( is_platform_mac(), "skip on mac for precision display issue on older mpl") - @pytest.mark.xfail(reason="suspect on mpl 2.2.2") def test_format_timedelta_ticks_narrow(self): if self.mpl_ge_2_0_0: @@ -1381,10 +1381,10 @@ def test_format_timedelta_ticks_narrow(self): for l, l_expected in zip(labels, expected_labels): assert l.get_text() == l_expected + @td.xfail_if_mpl_2_2 @pytest.mark.skip( is_platform_mac(), "skip on mac for precision display issue on older mpl") - @pytest.mark.xfail(reason="suspect on mpl 2.2.2") def test_format_timedelta_ticks_wide(self): if self.mpl_ge_2_0_0: diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py index 3d25b0b51e052..b29afcb404ac6 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -2461,6 +2461,7 @@ def test_errorbar_asymmetrical(self): tm.close() + @td.xfail_if_mpl_2_2 def test_table(self): df = DataFrame(np.random.rand(10, 3), index=list(string.ascii_letters[:10])) diff --git a/pandas/tests/plotting/test_misc.py b/pandas/tests/plotting/test_misc.py index 9e538ae130a85..c5ce8aba9d80e 100644 --- a/pandas/tests/plotting/test_misc.py +++ b/pandas/tests/plotting/test_misc.py @@ -52,6 +52,7 @@ def test_bootstrap_plot(self): @td.skip_if_no_mpl class TestDataFramePlots(TestPlotBase): + @td.xfail_if_mpl_2_2 @td.skip_if_no_scipy def test_scatter_matrix_axis(self): scatter_matrix = plotting.scatter_matrix diff --git a/pandas/tests/plotting/test_series.py b/pandas/tests/plotting/test_series.py index 278be433183fa..5dc7d52e05778 100644 --- a/pandas/tests/plotting/test_series.py +++ b/pandas/tests/plotting/test_series.py @@ -792,6 +792,7 @@ def test_errorbar_plot(self): with pytest.raises((ValueError, TypeError)): s.plot(yerr=s_err) + @td.xfail_if_mpl_2_2 def test_table(self): _check_plot_works(self.series.plot, table=True) _check_plot_works(self.series.plot, table=self.series) diff --git a/pandas/util/_test_decorators.py b/pandas/util/_test_decorators.py index b2745ab5eec77..8ad73538fbec1 100644 --- a/pandas/util/_test_decorators.py +++ b/pandas/util/_test_decorators.py @@ -89,6 +89,17 @@ def _skip_if_mpl_1_5(): mod.use("Agg", warn=False) +def _skip_if_mpl_2_2(): + mod = safe_import("matplotlib") + + if mod: + v = mod.__version__ + if LooseVersion(v) > LooseVersion('2.1.2'): + return True + else: + mod.use("Agg", warn=False) + + def _skip_if_has_locale(): lang, _ = locale.getlocale() if lang is not None: @@ -151,6 +162,8 @@ def decorated_func(func): reason="Missing matplotlib dependency") skip_if_mpl_1_5 = pytest.mark.skipif(_skip_if_mpl_1_5(), reason="matplotlib 1.5") +xfail_if_mpl_2_2 = pytest.mark.xfail(_skip_if_mpl_2_2(), + reason="matplotlib 2.2") skip_if_32bit = pytest.mark.skipif(is_platform_32bit(), reason="skipping for 32 bit") skip_if_windows = pytest.mark.skipif(is_platform_windows(),