コード例 #1
0
def test_eval_math_random_1():
    num1 = randint(0, 1000)
    num2 = randint(0, 1000)
    list_of_operators = ['+', '-', '*', '/', '**']
    op = choice(list_of_operators)
    str_input = f"{num1} {op} {num2}"
    ans = eval(str_input)
    if op == "**":
        str_input = f"{num1} ^ {num2}"
    expected = f"{str_input} = {ans}"
    assert(eval_math(str_input) == expected)
コード例 #2
0
def test_eval_math_simple_sub2():
    assert(eval_math("6 - 12") == "6 - 12 = -6")
コード例 #3
0
def test_eval_math_simple_sub():
    assert(eval_math("11 - 6") == "11 - 6 = 5")
コード例 #4
0
def test_eval_math_simple_add():
    assert(eval_math("10 + 6") == "10 + 6 = 16")
コード例 #5
0
def test_eval_math_simple_pow():
    assert(eval_math("3 ^ 4") == "3 ^ 4 = 81")
コード例 #6
0
def test_eval_math_simple_div():
    assert(eval_math("11 / 5") == "11 / 5 = 2.2")
コード例 #7
0
def test_eval_math_simple_mult():
    assert(eval_math("8 * 9") == "8 * 9 = 72")