def test_timeout_ok(self): if 'CallFunc' in unallowed_ast_nodes: return # disabled since function calls are disabled # attempt to exectute 'slow' code which finishes within timelimit def test(): time.sleep(2) env = {'test':test} safe_eval("test()", env, timeout_secs = 5)
def test_timeout_ok(self): if 'CallFunc' in unallowed_ast_nodes: return # disabled since function calls are disabled # attempt to exectute 'slow' code which finishes within timelimit def test(): time.sleep(2) env = {'test': test} safe_eval("test()", env, timeout_secs=5)
def test_callback(self): if 'CallFunc' in unallowed_ast_nodes: return # disabled since function calls are disabled # modify local variable via callback self.value = 0 def test(): self.value = 1 env = {'test':test} safe_eval("test()", env) self.assertEqual(self.value, 1)
def test_callback(self): if 'CallFunc' in unallowed_ast_nodes: return # disabled since function calls are disabled # modify local variable via callback self.value = 0 def test(): self.value = 1 env = {'test': test} safe_eval("test()", env) self.assertEqual(self.value, 1)