Exemple #1
0
def test_safe_eval5():
  assert safe_eval("myadd", globals())(3,39) == 42
  assert safe_eval("myaddcls", globals())(3,39) == 42
  assert safe_eval("myaddcls()", globals())(3,39) == 42
Exemple #2
0
def test_safe_eval4():
  assert safe_eval("myadd2(a=39)", globals(), b=3) == -42
  assert safe_eval("myadd2(a= 39)", globals(), b=3) == -42
  assert safe_eval("myadd2(a= 39, b = 3)", globals()) == -42
Exemple #3
0
def test_safe_eval2():
  s_add = [3, 39]
  assert safe_eval("add", globals(), *s_add) == 42
Exemple #4
0
def test_safe_eval3():
  assert safe_eval("myadd()", globals()) == 42
  assert safe_eval("myadd(a=39)", globals(), b=3) == 42
Exemple #5
0
def test_safe_eval1():
  s = "add(3,3)"
  assert safe_eval(s, globals()) == 6