Example #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}"
Example #2
0
def test_peek_implemented():
    assert hasattr(RPCalc(), 'peek'), \
        "peek not implemented"
Example #3
0
def test_peek():
    calc = RPCalc()
    calc.push(1)
    calc.peek()
    assert bool(calc), \
        "expected non-empty stack"
Example #4
0
def test_length():
    calc = RPCalc()
    calc.push(1)
    calc.push(2)
    calc.push("+")
    assert len(calc) == 1
Example #5
0
def test_pop():
    calc = RPCalc()
    calc.push(1)
    calc.pop()
    assert not bool(calc), \
        "expected empty stack"
Example #6
0
def test_pop_implemented():
    assert hasattr(RPCalc(), 'pop'), \
        "pop not implemented"
Example #7
0
def test_length_implemented():
    assert hasattr(RPCalc(), '__len__'), \
        "RPCalc has no len special method"
Example #8
0
def test_push(elements):
    calc = RPCalc()
    for element in elements:
        calc.push(element)
Example #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"