diff --git a/prog_question_test/tests/autograde.py b/prog_question_test/tests/autograde.py index 9d9b6cb..fe167e4 100755 --- a/prog_question_test/tests/autograde.py +++ b/prog_question_test/tests/autograde.py @@ -62,6 +62,20 @@ def is_recursion_node(func_def_node): self.assertTrue(is_recursion(user_function)) + @timeout_decorator.timeout(2) + def test_private_iteration(self): + def is_iteration(func): + children_nodes = list(ast.walk(ast.parse(inspect.getsource(func)))) + + return len(list(filter(lambda node: type(node) in (ast.For, ast.While), children_nodes))) > 0 + + self.meta['expression'] = 'test iteration' + self.meta['expected'] = 'True' + self.meta['output'] = str(is_iteration(user_function)) + self.meta['hint'] = 'Your function is not iterative.' + + self.assertTrue(is_iteration(user_function)) + class ProgQuestionEvaluation(unittest.TestCase): def setUp(self): # clears the dictionary containing meta data for each test