Skip to content

Commit e9c3e91

Browse files
committed
REF: Refactor binary operation tests for DataFrame and Series attributes
1 parent bf898c7 commit e9c3e91

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

pandas/tests/frame/test_api.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -324,15 +324,6 @@ def test_attrs_deepcopy(self):
324324
assert result.attrs == df.attrs
325325
assert result.attrs["tags"] is not df.attrs["tags"]
326326

327-
def test_attrs_binary_operations(self, all_binary_operators):
328-
# GH 51607
329-
df_1 = DataFrame([1])
330-
df_2 = DataFrame([2])
331-
attrs = {"info": "DataFrame"}
332-
df_1.attrs = attrs
333-
assert all_binary_operators(df_1, df_2).attrs == attrs
334-
assert all_binary_operators(df_2, df_1).attrs == attrs
335-
336327
@pytest.mark.parametrize("allows_duplicate_labels", [True, False, None])
337328
def test_set_flags(
338329
self,

pandas/tests/generic/test_finalize.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,22 @@ def test_binops(request, args, annotate, all_binary_operators):
450450
assert result.attrs == {"a": 1}
451451

452452

453+
@pytest.mark.parametrize(
454+
"left, right, attrs",
455+
[
456+
(pd.DataFrame([1]), pd.DataFrame([2]), {"a": 1}),
457+
(pd.Series([1]), pd.Series([2]), {"a": 1}),
458+
(pd.Series([1]), pd.DataFrame([2]), {"a": 1}),
459+
(pd.DataFrame([1]), pd.Series([2]), {"a": 1}),
460+
],
461+
)
462+
def test_attrs_binary_operations(all_binary_operators, left, right, attrs):
463+
# GH 51607
464+
left.attrs = attrs
465+
assert all_binary_operators(left, right).attrs == attrs
466+
assert all_binary_operators(right, left).attrs == attrs
467+
468+
453469
# ----------------------------------------------------------------------------
454470
# Accessors
455471

pandas/tests/series/test_api.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,6 @@ def test_attrs(self):
160160
result = s + 1
161161
assert result.attrs == {"version": 1}
162162

163-
def test_attrs_binary_operations(self, all_binary_operators):
164-
# GH 51607
165-
s1 = Series([1])
166-
s2 = Series([2])
167-
attrs = {"info": "Series"}
168-
s1.attrs = attrs
169-
assert all_binary_operators(s1, s2).attrs == attrs
170-
assert all_binary_operators(s2, s1).attrs == attrs
171-
172163
def test_inspect_getmembers(self):
173164
# GH38782
174165
ser = Series(dtype=object)

0 commit comments

Comments
 (0)