Skip to content

Commit 1682b92

Browse files
committed
update test
1 parent 86b26d2 commit 1682b92

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

pandas/tests/extension/base/ops.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,13 @@ def test_error(self, data, all_arithmetic_operators):
122122
with pytest.raises(AttributeError):
123123
getattr(data, op_name)
124124

125-
def test_direct_arith_with_series_returns_not_implemented(self, data):
126-
# EAs should return NotImplemented for ops with Series.
125+
@pytest.mark.parametrize("box", [pd.Series, pd.DataFrame])
126+
def test_direct_arith_with_ndframe_returns_not_implemented(self, data, box):
127+
# EAs should return NotImplemented for ops with Series/DataFrame
127128
# Pandas takes care of unboxing the series and calling the EA's op.
128129
other = pd.Series(data)
130+
if box is pd.DataFrame:
131+
other = other.to_frame()
129132
if hasattr(data, "__add__"):
130133
result = data.__add__(other)
131134
assert result is NotImplemented
@@ -164,10 +167,14 @@ def test_compare_array(self, data, all_compare_operators):
164167
other = pd.Series([data[0]] * len(data))
165168
self._compare_other(s, data, op_name, other)
166169

167-
def test_direct_arith_with_series_returns_not_implemented(self, data):
168-
# EAs should return NotImplemented for ops with Series.
170+
@pytest.mark.parametrize("box", [pd.Series, pd.DataFrame])
171+
def test_direct_arith_with_ndframe_returns_not_implemented(self, data, box):
172+
# EAs should return NotImplemented for ops with Series/DataFrame
169173
# Pandas takes care of unboxing the series and calling the EA's op.
170174
other = pd.Series(data)
175+
if box is pd.DataFrame:
176+
other = other.to_frame()
177+
171178
if hasattr(data, "__eq__"):
172179
result = data.__eq__(other)
173180
assert result is NotImplemented

pandas/tests/extension/test_period.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,13 @@ def test_add_series_with_extension_array(self, data):
126126
def test_error(self):
127127
pass
128128

129-
def test_direct_arith_with_series_returns_not_implemented(self, data):
129+
@pytest.mark.parametrize("box", [pd.Series, pd.DataFrame])
130+
def test_direct_arith_with_ndframe_returns_not_implemented(self, data, box):
130131
# Override to use __sub__ instead of __add__
131132
other = pd.Series(data)
133+
if box is pd.DataFrame:
134+
other = other.to_frame()
135+
132136
result = data.__sub__(other)
133137
assert result is NotImplemented
134138

0 commit comments

Comments
 (0)