summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/evaluator_tests/test_python_evaluation.py36
1 files changed, 23 insertions, 13 deletions
diff --git a/yaksh/evaluator_tests/test_python_evaluation.py b/yaksh/evaluator_tests/test_python_evaluation.py
index b71154a..7cd4352 100644
--- a/yaksh/evaluator_tests/test_python_evaluation.py
+++ b/yaksh/evaluator_tests/test_python_evaluation.py
@@ -4,15 +4,16 @@ from yaksh.python_code_evaluator import PythonCodeEvaluator
from yaksh.settings import SERVER_TIMEOUT
from textwrap import dedent
+
class PythonEvaluationTestCases(unittest.TestCase):
def setUp(self):
self.language = "Python"
self.test = None
self.test_case_data = [{"func_name": "add",
- "expected_answer": "5",
- "test_id": u'null',
- "pos_args": ["3", "2"],
- "kw_args": {}
+ "expected_answer": "5",
+ "test_id": u'null',
+ "pos_args": ["3", "2"],
+ "kw_args": {}
}]
def test_correct_answer(self):
@@ -20,7 +21,8 @@ class PythonEvaluationTestCases(unittest.TestCase):
def add(a, b):
return a + b
""")
- get_evaluator = PythonCodeEvaluator(self.test_case_data, self.test, self.language, user_answer, ref_code_path=None, in_dir=None)
+ get_evaluator = PythonCodeEvaluator(self.test_case_data, self.test,
+ self.language, user_answer)
result = get_evaluator.evaluate()
self.assertTrue(result.get("success"))
self.assertEqual(result.get("error"), "Correct answer")
@@ -30,7 +32,8 @@ class PythonEvaluationTestCases(unittest.TestCase):
def add(a, b):
return a - b
""")
- get_evaluator = PythonCodeEvaluator(self.test_case_data, self.test, self.language, user_answer, ref_code_path=None, in_dir=None)
+ get_evaluator = PythonCodeEvaluator(self.test_case_data, self.test,
+ self.language, user_answer)
result = get_evaluator.evaluate()
self.assertFalse(result.get("success"))
self.assertEqual(result.get("error"), "AssertionError in: assert add(3, 2) == 5")
@@ -43,7 +46,8 @@ class PythonEvaluationTestCases(unittest.TestCase):
""")
timeout_msg = ("Code took more than {0} seconds to run. "
"You probably have an infinite loop in your code.").format(SERVER_TIMEOUT)
- get_evaluator = PythonCodeEvaluator(self.test_case_data, self.test, self.language, user_answer, ref_code_path=None, in_dir=None)
+ get_evaluator = PythonCodeEvaluator(self.test_case_data, self.test,
+ self.language, user_answer)
result = get_evaluator.evaluate()
self.assertFalse(result.get("success"))
self.assertEquals(result.get("error"), timeout_msg)
@@ -54,7 +58,8 @@ class PythonEvaluationTestCases(unittest.TestCase):
return a + b
""")
syntax_error_msg = "SyntaxError"
- get_evaluator = PythonCodeEvaluator(self.test_case_data, self.test, self.language, user_answer, ref_code_path=None, in_dir=None)
+ get_evaluator = PythonCodeEvaluator(self.test_case_data, self.test,
+ self.language, user_answer)
result = get_evaluator.evaluate()
self.assertFalse(result.get("success"))
self.assertIn(syntax_error_msg, result.get("error"))
@@ -65,7 +70,8 @@ class PythonEvaluationTestCases(unittest.TestCase):
return a + b
""")
indent_error_msg = "IndentationError"
- get_evaluator = PythonCodeEvaluator(self.test_case_data, self.test, self.language, user_answer, ref_code_path=None, in_dir=None)
+ get_evaluator = PythonCodeEvaluator(self.test_case_data, self.test,
+ self.language, user_answer)
result = get_evaluator.evaluate()
self.assertFalse(result.get("success"))
self.assertIn(indent_error_msg, result.get("error"))
@@ -73,7 +79,8 @@ class PythonEvaluationTestCases(unittest.TestCase):
def test_name_error(self):
user_answer = ""
name_error_msg = "NameError"
- get_evaluator = PythonCodeEvaluator(self.test_case_data, self.test, self.language, user_answer, ref_code_path=None, in_dir=None)
+ get_evaluator = PythonCodeEvaluator(self.test_case_data, self.test,
+ self.language, user_answer)
result = get_evaluator.evaluate()
self.assertFalse(result.get("success"))
self.assertIn(name_error_msg, result.get("error"))
@@ -84,7 +91,8 @@ class PythonEvaluationTestCases(unittest.TestCase):
return add(3, 3)
""")
recursion_error_msg = "RuntimeError"
- get_evaluator = PythonCodeEvaluator(self.test_case_data, self.test, self.language, user_answer, ref_code_path=None, in_dir=None)
+ get_evaluator = PythonCodeEvaluator(self.test_case_data, self.test,
+ self.language, user_answer)
result = get_evaluator.evaluate()
self.assertFalse(result.get("success"))
self.assertIn(recursion_error_msg, result.get("error"))
@@ -95,7 +103,8 @@ class PythonEvaluationTestCases(unittest.TestCase):
return a + b
""")
type_error_msg = "TypeError"
- get_evaluator = PythonCodeEvaluator(self.test_case_data, self.test, self.language, user_answer, ref_code_path=None, in_dir=None)
+ get_evaluator = PythonCodeEvaluator(self.test_case_data, self.test,
+ self.language, user_answer)
result = get_evaluator.evaluate()
self.assertFalse(result.get("success"))
self.assertIn(type_error_msg, result.get("error"))
@@ -107,7 +116,8 @@ class PythonEvaluationTestCases(unittest.TestCase):
return int(a) + int(b) + int(c)
""")
value_error_msg = "ValueError"
- get_evaluator = PythonCodeEvaluator(self.test_case_data, self.test, self.language, user_answer, ref_code_path=None, in_dir=None)
+ get_evaluator = PythonCodeEvaluator(self.test_case_data, self.test,
+ self.language, user_answer)
result = get_evaluator.evaluate()
self.assertFalse(result.get("success"))
self.assertIn(value_error_msg, result.get("error"))