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

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

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