Skip to content

Commit b6ad2fb

Browse files
base tests
1 parent 375664c commit b6ad2fb

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

pandas/tests/extension/base/ops.py

+10
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,16 @@ def test_compare_array(self, data, all_compare_operators):
164164
other = pd.Series([data[0]] * len(data))
165165
self._compare_other(s, data, op_name, other)
166166

167+
def test_direct_arith_with_series_returns_not_implemented(self, data):
168+
# EAs should return NotImplemented for ops with Series.
169+
# Pandas takes care of unboxing the series and calling the EA's op.
170+
other = pd.Series(data)
171+
if hasattr(data, "__eq__"):
172+
result = data.__eq__(other)
173+
assert result is NotImplemented
174+
else:
175+
raise pytest.skip(f"{type(data).__name__} does not implement __eq__")
176+
167177

168178
class BaseUnaryOpsTests(BaseOpsUtil):
169179
def test_invert(self, data):

pandas/tests/extension/json/array.py

+6
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ def __setitem__(self, key, value):
105105
def __len__(self) -> int:
106106
return len(self.data)
107107

108+
def __eq__(self, other):
109+
return NotImplemented
110+
111+
def __ne__(self, other):
112+
return NotImplemented
113+
108114
def __array__(self, dtype=None):
109115
if dtype is None:
110116
dtype = object

0 commit comments

Comments
 (0)