def test_many_items_middle(self): mylist = OrderedList() mylist.add(1) mylist.add(2) mylist.add(3) assert mylist.pop(-2) == 2 assert mylist.size() == 2
def test_many_items_last(self): mylist = OrderedList() mylist.add(1) mylist.add(2) mylist.add(3) assert mylist.pop(-1) == 3 assert mylist.size() == 2
def test_many_items_first(self): mylist = OrderedList() mylist.add(1) mylist.add(2) mylist.add(3) assert mylist.pop(0) == 1 assert mylist.size() == 2
def test_non_integer_pos(self): with pytest.raises(TypeError): mylist = OrderedList() mylist.add(3) mylist.pop(.4)
def test_empty_list(self): with pytest.raises(IndexError): mylist = OrderedList() mylist.pop()
def test_one_item_last(self): mylist = OrderedList() mylist.add(2) assert mylist.pop(-1) == 2 assert mylist.isEmpty()
def test_index_out_of_range_low(self): with pytest.raises(IndexError): mylist = OrderedList() mylist.add(2) mylist.pop(-100)