def test_using_list_as_stack(self): stack = RedisList((3, 4, 5)) stack.append(6) stack.append(7) assert stack == [3, 4, 5, 6, 7] assert stack.pop() == 7 assert stack == [3, 4, 5, 6] assert stack.pop() == 6 assert stack.pop() == 5 assert stack == [3, 4]
def test_pop_index(self): metasyntactic = RedisList( ('foo', 'bar', 'baz', 'qux', 'quux', 'corge', 'grault', 'garply', 'waldo', 'fred', 'plugh', 'xyzzy', 'thud'), redis=self.redis, ) assert metasyntactic.pop(1) == 'bar'
def test_more_on_lists(self): a = RedisList((66.25, 333, 333, 1, 1234.5)) assert (a.count(333), a.count(66.25), a.count('x')) == (2, 1, 0) a.insert(2, -1) a.append(333) assert a == [66.25, 333, -1, 333, 1, 1234.5, 333] assert a.index(333) == 1 a.remove(333) assert a == [66.25, -1, 333, 1, 1234.5, 333] a.reverse() assert a == [333, 1234.5, 1, 333, -1, 66.25] a.sort() assert a == [-1, 1, 66.25, 333, 333, 1234.5] assert a.pop() == 1234.5 assert a == [-1, 1, 66.25, 333, 333]
def test_pop_index(self): metasyntactic = RedisList(( 'foo', 'bar', 'baz', 'qux', 'quux', 'corge', 'grault', 'garply', 'waldo', 'fred', 'plugh', 'xyzzy', 'thud', )) assert metasyntactic.pop(1) == 'bar'
def test_pop_out_of_range(self): squares = RedisList((1, 4, 9, 16, 25)) with self.assertRaises(IndexError): squares.pop(len(squares))