Skip to content

Commit b3c8e7b

Browse files
second attempt to fixup test
1 parent b28362f commit b3c8e7b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pandas/tests/indexing/test_loc.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,13 +2087,14 @@ def test_loc_setitem_datetime_keys_cast(self, conv, using_infer_string):
20872087
# the dtype constructed by Index([..]) does not yet follow the unit
20882088
# of the input on 2.3.x -> so checking this is datetime64, but then
20892089
# specifying the exact dtype in the expected result
2090-
assert df.index.dtype.kind == "M"
2090+
if using_infer_string:
2091+
assert df.index.dtype.kind == "M"
2092+
exp_dtype = df.index.dtype
2093+
else:
2094+
exp_dtype = "datetime64[ns]"
20912095
expected = DataFrame(
20922096
{"one": [100.0, 200.0]},
2093-
index=Index(
2094-
[conv(dt1), conv(dt2)],
2095-
dtype=df.index.dtype if using_infer_string else object,
2096-
),
2097+
index=Index([dt1, dt2], dtype=exp_dtype),
20972098
columns=Index(["one"]),
20982099
)
20992100
tm.assert_frame_equal(df, expected)

0 commit comments

Comments
 (0)