예제 #1
0
 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
예제 #2
0
 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
예제 #3
0
 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
예제 #4
0
 def test_non_integer_pos(self):
     with pytest.raises(TypeError):
         mylist = OrderedList()
         mylist.add(3)
         mylist.pop(.4)
예제 #5
0
 def test_empty_list(self):
     with pytest.raises(IndexError):
         mylist = OrderedList()
         mylist.pop()
예제 #6
0
 def test_one_item_last(self):
     mylist = OrderedList()
     mylist.add(2)
     assert mylist.pop(-1) == 2
     assert mylist.isEmpty()
예제 #7
0
 def test_index_out_of_range_low(self):
     with pytest.raises(IndexError):
         mylist = OrderedList()
         mylist.add(2)
         mylist.pop(-100)