def test_many_pops(self): ss = StackSet() self.fill_stack(ss, 10000) for i in xrange(0, 9000): ss.pop() assert len(ss) == 1000 assert ss.peek() == 999
def test_push_into_empty(self): ss = StackSet() ss.push('hi') assert len(ss) == 1 assert ss.peek() == 'hi' k = ss.pop() assert len(ss) == 0 assert k == 'hi'
def test_push_multiple_replace_multiple(self): ss = StackSet() self.fill_stack(ss, 100) ss.push(5) ss.push(50) ss.push(55) ss.push(105) assert 5 in ss assert 50 in ss assert 55 in ss assert 105 in ss assert len(ss) == 101 assert ss.peek() == 105
def test_empty_repr(self): ss = StackSet() assert ss.peek() is None assert repr(ss) == 'StackSet([])'
def test_str(self): ss = StackSet() self.fill_stack(ss, 5) assert ss.peek() == 4 assert str(ss) == '[0, 1, 2, 3, 4]'
def test_cons3(self): ss = StackSet([1,2,3,4,5]) assert len(ss) == 5 assert ss.peek() == 5
def test_cons1(self): ss = StackSet() assert len(ss) == 0 assert ss.peek() is None