예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
    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)
예제 #4
0
    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)