Example #1
0
def test_simple_addition():
    assert evaluate('1 + 2') == 3
Example #2
0
def test_literal():
    assert evaluate('42') == 42
Example #3
0
def test_error_eof():
    with pytest.raises(SyntaxError) as excinfo:
        evaluate('1 +')

    assert excinfo.value.args[0] == 'unexpected end of source'
Example #4
0
def test_error_null_src():
    assert evaluate('  ') is None
Example #5
0
def test_error_plus():
    with pytest.raises(SyntaxError) as excinfo:
        evaluate('+')

    assert excinfo.value.args[0] == "unexpected '+' in line:\n+"
Example #6
0
def test_long_addition():
    assert evaluate('1 + 2 + 3 + 4 + 5') == 15