This commit is contained in:
+10
-10
@@ -31,17 +31,17 @@ def test_arithmetic_eval_valid(expr, expected):
|
||||
assert arithmetic_eval(expr) == expected
|
||||
|
||||
# Expressions with unsupported operations or node types
|
||||
@pytest.mark.parametrize("expr", [
|
||||
"2 ** 3", # power operator not supported
|
||||
"3 << 1", # bitwise shift not supported
|
||||
"1 < 2", # comparison not supported
|
||||
"abs(3)", # function call not supported
|
||||
"a + 2", # undefined variable
|
||||
"[1, 2] + [3]", # lists not supported
|
||||
"{1: 2}", # dicts not supported
|
||||
@pytest.mark.parametrize("expr, expected_message", [
|
||||
("2 ** 3", "Unsupported BinOp Pow"),
|
||||
("3 << 1", "Unsupported BinOp LShift"),
|
||||
("1 < 2", "Unsupported BinOp Lt"),
|
||||
("abs(3)", "Unsupported Call"),
|
||||
("a + 2", "Unsupported Name"),
|
||||
("[1, 2] + [3]", "Unsupported constant type: list"),
|
||||
("{1: 2}", "Unsupported constant type: dict"),
|
||||
])
|
||||
def test_arithmetic_eval_raises(expr):
|
||||
with pytest.raises(ArithmeticEvalError):
|
||||
def test_arithmetic_eval_raises_with_message(expr, expected_message):
|
||||
with pytest.raises(ArithmeticEvalError, match=expected_message):
|
||||
arithmetic_eval(expr)
|
||||
|
||||
# Expressions that are syntactically valid but cause Python runtime errors
|
||||
|
||||
Reference in New Issue
Block a user