Skip to content

Commit c997161

Browse files
committed
address PR comment: construct DaataFrame in the body of test
1 parent a44af1a commit c997161

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

pandas/tests/indexing/test_loc.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -259,20 +259,21 @@ def test_loc_getitem_single_boolean_arg(self, obj, key, exp):
259259
assert res == exp
260260

261261
@pytest.mark.parametrize(
262-
"obj",
262+
"data",
263263
[
264-
DataFrame({"A": [datetime(2025, 10, 30)]}),
265-
DataFrame({"A": [Timestamp(2025, 10, 30)] * 2}),
266-
DataFrame({"A": [Timedelta(1)]}),
267-
DataFrame({"A": [Timedelta(1), Timedelta(2)]}),
264+
[datetime(2025, 10, 30)],
265+
[Timestamp(2025, 10, 30)] * 2,
266+
[Timedelta(1)],
267+
[Timedelta(1), Timedelta(2)],
268268
],
269269
)
270-
def test_loc_empty_slice_assignment_with_datetime(self, obj):
270+
def test_loc_empty_slice_assignment_with_datetime(self, data):
271271
# issue #50942
272272
# empty slice assignment with datetime or timedelta should not raise exceptions
273-
mask = [False] * len(obj)
273+
mask = [False] * len(data)
274274
try:
275-
obj.loc[mask] = obj
275+
df = DataFrame(data=data, columns=["A"])
276+
df.loc[mask] = df
276277
assert True
277278
except Exception:
278279
pytest.fail("loc empty slice assignment raised Exception unexpectedly!")

0 commit comments

Comments
 (0)