Exemple #1
0
def test_calculator_arithmetic(expression, answer):
    calc = RPCalc()
    for element in expression:
        calc.push(element)
    assert calc.peek() == answer, \
        f"expected an answer of {answer}"
Exemple #2
0
def test_peek_implemented():
    assert hasattr(RPCalc(), 'peek'), \
        "peek not implemented"
Exemple #3
0
def test_peek():
    calc = RPCalc()
    calc.push(1)
    calc.peek()
    assert bool(calc), \
        "expected non-empty stack"
Exemple #4
0
def test_length():
    calc = RPCalc()
    calc.push(1)
    calc.push(2)
    calc.push("+")
    assert len(calc) == 1
Exemple #5
0
def test_pop():
    calc = RPCalc()
    calc.push(1)
    calc.pop()
    assert not bool(calc), \
        "expected empty stack"
Exemple #6
0
def test_pop_implemented():
    assert hasattr(RPCalc(), 'pop'), \
        "pop not implemented"
Exemple #7
0
def test_length_implemented():
    assert hasattr(RPCalc(), '__len__'), \
        "RPCalc has no len special method"
Exemple #8
0
def test_push(elements):
    calc = RPCalc()
    for element in elements:
        calc.push(element)
Exemple #9
0
def test_push_implemented():
    assert hasattr(RPCalc(), 'push'), \
        "push not implemented"
def test_peek_implemented():
    assert hasattr(RPCalc(), "peek"), "peek not implemented"
def test_pop_implemented():
    assert hasattr(RPCalc(), "pop"), "pop not implemented"
def test_push_implemented():
    assert hasattr(RPCalc(), "push"), "push not implemented"