Skip to content
9 changes: 9 additions & 0 deletions pandas/tests/indexes/timedeltas/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@ def test_take_fill_value(self):


class TestTimedeltaIndex:
def test_insert_empty(self):
# Corner case inserting with length zero doesnt raise IndexError
idx = timedelta_range("1 Day", periods=3)
td = idx[0]

idx[:0].insert(0, td)
idx[:0].insert(1, td)
idx[:0].insert(-1, td)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe worth comparing the results

def test_insert(self):

idx = TimedeltaIndex(["4day", "1day", "2day"], name="idx")
Expand Down