コード例 #1
0
def test_p1_v1(a):
    s = Stack()
    for x in a:
        s.push(x)
    while s.len() > 0:
        s.pop()
    assert s.pop() == None
    assert s.len() == 0
コード例 #2
0
def test_p9_len_is_side_effect_free(values):
    stack = Stack()
    for v in values:
        stack.push(v)
    stack.len()
    for v in reversed(values):
        assert stack.pop() == v
    assert stack.pop() == None
コード例 #3
0
def test_p1_v2(a):
    s = Stack()
    for x in a:
        s.push(x)
    for x in a:
        s.pop()
    assert s.pop() == None
    assert s.len() == 0
コード例 #4
0
def test_p10_push_does_not_return_value(values):
    stack = Stack()
    for v in values:
        assert stack.push(v) == None
コード例 #5
0
def test_p4_pushing_None_raises_ValueError(v):
    stack = Stack()
    if v == None:
        with pytest.raises(ValueError):
            s.push(v)
コード例 #6
0
def test_p1_lifo(values):
    stack = Stack()
    for v in values:
        stack.push(v)
    for v in reversed(values):
        assert stack.pop() == v
コード例 #7
0
def populate_stack(values):
    stack=Stack()
    for v in values:
        stack.push(v)
    return stack
コード例 #8
0
def test_p4_pushing_None_raises_ValueError():
    s = Stack()
    with pytest.raises(ValueError):
        s.push(None)