Skip to content
Prev Previous commit
Next Next commit
update test
  • Loading branch information
jbrockmendel committed Sep 28, 2022
commit 5b7a570f8fff0fb79188445a3f70fadd259da527
4 changes: 2 additions & 2 deletions pandas/tests/indexes/datetimes/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,15 +390,15 @@ def test_take_fill_value_with_timezone(self):
class TestGetLoc:
def test_get_loc_key_unit_mismatch(self):
idx = date_range("2000-01-01", periods=3)
key = idx[1]._as_unit("ms")
key = idx[1].as_unit("ms")
loc = idx.get_loc(key)
assert loc == 1
assert key in idx

def test_get_loc_key_unit_mismatch_not_castable(self):
dta = date_range("2000-01-01", periods=3)._data.astype("M8[s]")
dti = DatetimeIndex(dta)
key = dta[0]._as_unit("ns") + pd.Timedelta(1)
key = dta[0].as_unit("ns") + pd.Timedelta(1)

with pytest.raises(
KeyError, match=r"Timestamp\('2000-01-01 00:00:00.000000001'\)"
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/indexes/timedeltas/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def test_timestamp_invalid_key(self, key):
class TestGetLoc:
def test_get_loc_key_unit_mismatch(self):
idx = to_timedelta(["0 days", "1 days", "2 days"])
key = idx[1]._as_unit("ms")
key = idx[1].as_unit("ms")
loc = idx.get_loc(key)
assert loc == 1

Expand All @@ -89,7 +89,7 @@ def test_get_loc_key_unit_mismatch_not_castable(self):
tda2 = type(tda)._simple_new(arr, dtype=arr.dtype)
tdi = TimedeltaIndex(tda2)
assert tdi.dtype == "m8[s]"
key = tda[0]._as_unit("ns") + Timedelta(1)
key = tda[0].as_unit("ns") + Timedelta(1)

with pytest.raises(KeyError, match=r"Timedelta\('0 days 00:00:00.000000001'\)"):
tdi.get_loc(key)
Expand Down