Skip to content

Commit 9b49486

Browse files
authored
TST: Add SparseArray _arith_method test to fail on incorrect comparison operator (#59648)
* Test * Match * Rerun GitHub actions * Initialize inside func
1 parent c345ffd commit 9b49486

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pandas/tests/arrays/sparse/test_arithmetics.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,19 @@ def test_mismatched_length_cmp_op(cons):
468468
left & right
469469

470470

471+
@pytest.mark.parametrize(
472+
"a, b",
473+
[
474+
([0, 1, 2], [0, 1, 2, 3]),
475+
([0, 1, 2, 3], [0, 1, 2]),
476+
],
477+
)
478+
def test_mismatched_length_arith_op(a, b, all_arithmetic_functions):
479+
op = all_arithmetic_functions
480+
with pytest.raises(AssertionError, match=f"length mismatch: {len(a)} vs. {len(b)}"):
481+
op(SparseArray(a, fill_value=0), np.array(b))
482+
483+
471484
@pytest.mark.parametrize("op", ["add", "sub", "mul", "truediv", "floordiv", "pow"])
472485
@pytest.mark.parametrize("fill_value", [np.nan, 3])
473486
def test_binary_operators(op, fill_value):

0 commit comments

Comments
 (0)