コード例 #1
0
 def test_insert(self):
     items = ItemList(str)
     items.insert(0, 'a')
     items.insert(0, 'b')
     items.insert(3, 'c')
     items.insert(1, 'd')
     assert_equal(list(items), ['b', 'd', 'a', 'c'])
コード例 #2
0
 def test_insert(self):
     items = ItemList(str)
     items.insert(0, 'a')
     items.insert(0, 'b')
     items.insert(3, 'c')
     items.insert(1, 'd')
     assert_equal(list(items), ['b', 'd', 'a', 'c'])
コード例 #3
0
 def test_modifications_during_iter(self):
     chars = ItemList(str, items='abdx')
     for c in chars:
         if c == 'a':
             chars.pop()
         if c == 'b':
             chars.insert(2, 'c')
         if c == 'c':
             chars.append('e')
         assert_true(c in 'abcde', '%s was unexpected here!' % c)
     assert_equal(list(chars), list('abcde'))
コード例 #4
0
 def test_modifications_during_reversed(self):
     chars = ItemList(str, items='yxdba')
     for c in reversed(chars):
         if c == 'a':
             chars.remove('x')
         if c == 'b':
             chars.insert(-2, 'c')
         if c == 'c':
             chars.pop(0)
         if c == 'd':
             chars.insert(0, 'e')
         assert_true(c in 'abcde', '%s was unexpected here!' % c)
     assert_equal(list(chars), list('edcba'))