Skip to content

Commit a8421c9

Browse files
jbrockmendeljreback
authored andcommitted
TST: stop suppressing plot test exceptions, xfail broken test (#29099)
1 parent d14219e commit a8421c9

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

pandas/tests/plotting/common.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from pandas.core.dtypes.api import is_list_like
1414

15+
import pandas as pd
1516
from pandas import DataFrame, Series
1617
import pandas.util.testing as tm
1718
from pandas.util.testing import assert_is_valid_plot_return_object, ensure_clean
@@ -541,13 +542,13 @@ def _check_plot_works(f, filterwarnings="always", **kwargs):
541542

542543
assert_is_valid_plot_return_object(ret)
543544

544-
try:
545-
kwargs["ax"] = fig.add_subplot(212)
546-
ret = f(**kwargs)
547-
except Exception:
548-
pass
545+
if f is pd.plotting.bootstrap_plot:
546+
assert "ax" not in kwargs
549547
else:
550-
assert_is_valid_plot_return_object(ret)
548+
kwargs["ax"] = fig.add_subplot(212)
549+
550+
ret = f(**kwargs)
551+
assert_is_valid_plot_return_object(ret)
551552

552553
with ensure_clean(return_filelike=True) as path:
553554
plt.savefig(path)

pandas/tests/plotting/test_frame.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
""" Test cases for DataFrame.plot """
44

55
from datetime import date, datetime
6+
import itertools
67
import string
78
import warnings
89

@@ -2604,12 +2605,6 @@ def test_errorbar_plot(self):
26042605
ax = _check_plot_works(df.plot, yerr=np.ones((2, 12)) * 0.4)
26052606
self._check_has_errorbars(ax, xerr=0, yerr=2)
26062607

2607-
# yerr is iterator
2608-
import itertools
2609-
2610-
ax = _check_plot_works(df.plot, yerr=itertools.repeat(0.1, len(df)))
2611-
self._check_has_errorbars(ax, xerr=0, yerr=2)
2612-
26132608
# yerr is column name
26142609
for yerr in ["yerr", "誤差"]:
26152610
s_df = df.copy()
@@ -2626,6 +2621,17 @@ def test_errorbar_plot(self):
26262621
with pytest.raises((ValueError, TypeError)):
26272622
df.plot(yerr=df_err)
26282623

2624+
@pytest.mark.xfail(reason="Iterator is consumed", raises=ValueError)
2625+
@pytest.mark.slow
2626+
def test_errorbar_plot_iterator(self):
2627+
with warnings.catch_warnings():
2628+
d = {"x": np.arange(12), "y": np.arange(12, 0, -1)}
2629+
df = DataFrame(d)
2630+
2631+
# yerr is iterator
2632+
ax = _check_plot_works(df.plot, yerr=itertools.repeat(0.1, len(df)))
2633+
self._check_has_errorbars(ax, xerr=0, yerr=2)
2634+
26292635
@pytest.mark.slow
26302636
def test_errorbar_with_integer_column_names(self):
26312637
# test with integer column names

0 commit comments

Comments
 (0)