summaryrefslogtreecommitdiff
path: root/yaksh/evaluator_tests
diff options
context:
space:
mode:
authorankitjavalkar2016-04-06 11:26:52 +0530
committerankitjavalkar2016-05-05 19:16:26 +0530
commitd3241512c71d61b355358a691d18e4ff8a8df34c (patch)
tree0d1810fab8a10b7671400dab64a8b877b334a676 /yaksh/evaluator_tests
parentf120f5763904589d3c18b6cc0f4e227bcaef9a0a (diff)
downloadonline_test-d3241512c71d61b355358a691d18e4ff8a8df34c.tar.gz
online_test-d3241512c71d61b355358a691d18e4ff8a8df34c.tar.bz2
online_test-d3241512c71d61b355358a691d18e4ff8a8df34c.zip
Multiple test cases passed as dicts, check_code() is iterated based on no. of test cases
Diffstat (limited to 'yaksh/evaluator_tests')
-rw-r--r--yaksh/evaluator_tests/test_bash_evaluation.py2
-rw-r--r--yaksh/evaluator_tests/test_c_cpp_evaluation.py4
-rw-r--r--yaksh/evaluator_tests/test_java_evaluation.py2
-rw-r--r--yaksh/evaluator_tests/test_python_evaluation.py15
-rw-r--r--yaksh/evaluator_tests/test_scilab_evaluation.py2
5 files changed, 14 insertions, 11 deletions
diff --git a/yaksh/evaluator_tests/test_bash_evaluation.py b/yaksh/evaluator_tests/test_bash_evaluation.py
index 5fa3d2d..39247f7 100644
--- a/yaksh/evaluator_tests/test_bash_evaluation.py
+++ b/yaksh/evaluator_tests/test_bash_evaluation.py
@@ -5,7 +5,7 @@ from yaksh.settings import SERVER_TIMEOUT
class BashEvaluationTestCases(unittest.TestCase):
def setUp(self):
- self.test_case_data = ["bash_files/sample.sh,bash_files/sample.args"]
+ self.test_case_data = [{"test_case": "bash_files/sample.sh,bash_files/sample.args"}]
self.in_dir = "/tmp"
self.timeout_msg = ("Code took more than {0} seconds to run. "
"You probably have an infinite loop in your code.").format(SERVER_TIMEOUT)
diff --git a/yaksh/evaluator_tests/test_c_cpp_evaluation.py b/yaksh/evaluator_tests/test_c_cpp_evaluation.py
index 9d37fb4..a07150d 100644
--- a/yaksh/evaluator_tests/test_c_cpp_evaluation.py
+++ b/yaksh/evaluator_tests/test_c_cpp_evaluation.py
@@ -5,7 +5,7 @@ from yaksh.settings import SERVER_TIMEOUT
class CEvaluationTestCases(unittest.TestCase):
def setUp(self):
- self.test_case_data = ["c_cpp_files/main.cpp"]
+ self.test_case_data = [{"test_case": "c_cpp_files/main.cpp"}]
self.in_dir = "/tmp"
self.timeout_msg = ("Code took more than {0} seconds to run. "
"You probably have an infinite loop in your code.").format(SERVER_TIMEOUT)
@@ -23,7 +23,7 @@ class CEvaluationTestCases(unittest.TestCase):
def test_incorrect_answer(self):
user_answer = "int add(int a, int b)\n{return a-b;}"
get_class = CppCodeEvaluator(self.in_dir)
- kwargs = {'user_answer': user_answer,
+ kwargs = {'user_answer': user_answer,
'test_case_data': self.test_case_data
}
result = get_class.evaluate(**kwargs)
diff --git a/yaksh/evaluator_tests/test_java_evaluation.py b/yaksh/evaluator_tests/test_java_evaluation.py
index a5852a3..eacd62e 100644
--- a/yaksh/evaluator_tests/test_java_evaluation.py
+++ b/yaksh/evaluator_tests/test_java_evaluation.py
@@ -7,7 +7,7 @@ from yaksh.settings import SERVER_TIMEOUT
class JavaEvaluationTestCases(unittest.TestCase):
def setUp(self):
- self.test_case_data = ["java_files/main_square.java"]
+ self.test_case_data = [{"test_case": "java_files/main_square.java"}]
self.in_dir = "/tmp"
evaluator.SERVER_TIMEOUT = 9
self.timeout_msg = ("Code took more than {0} seconds to run. "
diff --git a/yaksh/evaluator_tests/test_python_evaluation.py b/yaksh/evaluator_tests/test_python_evaluation.py
index b23942f..39d4723 100644
--- a/yaksh/evaluator_tests/test_python_evaluation.py
+++ b/yaksh/evaluator_tests/test_python_evaluation.py
@@ -8,7 +8,10 @@ from textwrap import dedent
class PythonAssertionEvaluationTestCases(unittest.TestCase):
def setUp(self):
- self.test_case_data = ['assert(add(1,2)==3)']
+ self.test_case_data = [{"test_case": 'assert(add(1,2)==3)'},
+ {"test_case": 'assert(add(-1,2)==1)'},
+ {"test_case": 'assert(add(-1,-2)==-3)'},
+ ]
self.timeout_msg = ("Code took more than {0} seconds to run. "
"You probably have an infinite loop in your code.").format(SERVER_TIMEOUT)
@@ -148,7 +151,7 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase):
class PythonStdoutEvaluationTestCases(unittest.TestCase):
def setUp(self):
- self.output = ['0 1 1 2 3']
+ self.test_case_data = [{"expected_output": "0 1 1 2 3"}]
self.timeout_msg = ("Code took more than {0} seconds to run. "
"You probably have an infinite loop in your code.").format(SERVER_TIMEOUT)
@@ -157,7 +160,7 @@ class PythonStdoutEvaluationTestCases(unittest.TestCase):
user_answer = "a,b=0,1\nfor i in range(5):\n\tprint a,\n\ta,b=b,a+b"
get_class = PythonStdoutEvaluator()
kwargs = {'user_answer': user_answer,
- 'test_case_data': self.output
+ 'test_case_data': self.test_case_data
}
result = get_class.evaluate(**kwargs)
self.assertEqual(result.get('error'), "Correct answer")
@@ -167,7 +170,7 @@ class PythonStdoutEvaluationTestCases(unittest.TestCase):
user_answer = "a,b=0,1\nfor i in range(5):\n\tprint b,\n\ta,b=b,a+b"
get_class = PythonStdoutEvaluator()
kwargs = {'user_answer': user_answer,
- 'test_case_data': self.output
+ 'test_case_data': self.test_case_data
}
result = get_class.evaluate(**kwargs)
self.assertFalse(result.get('success'))
@@ -178,7 +181,7 @@ class PythonStdoutEvaluationTestCases(unittest.TestCase):
error_msg = "Incorrect Answer: Please avoid printing the expected output directly"
get_class = PythonStdoutEvaluator()
kwargs = {'user_answer': user_answer,
- 'test_case_data': self.output
+ 'test_case_data': self.test_case_data
}
result = get_class.evaluate(**kwargs)
self.assertFalse(result.get('success'))
@@ -188,7 +191,7 @@ class PythonStdoutEvaluationTestCases(unittest.TestCase):
user_answer = "def add(a, b):\n\twhile True:\n\t\tpass"
get_class = PythonStdoutEvaluator()
kwargs = {'user_answer': user_answer,
- 'test_case_data': self.output
+ 'test_case_data': self.test_case_data
}
result = get_class.evaluate(**kwargs)
self.assertFalse(result.get('success'))
diff --git a/yaksh/evaluator_tests/test_scilab_evaluation.py b/yaksh/evaluator_tests/test_scilab_evaluation.py
index 2b459fc..928cd7e 100644
--- a/yaksh/evaluator_tests/test_scilab_evaluation.py
+++ b/yaksh/evaluator_tests/test_scilab_evaluation.py
@@ -6,7 +6,7 @@ from yaksh.settings import SERVER_TIMEOUT
class ScilabEvaluationTestCases(unittest.TestCase):
def setUp(self):
- self.test_case_data = ["scilab_files/test_add.sce"]
+ self.test_case_data = [{"test_case": "scilab_files/test_add.sce"}]
self.in_dir = "/tmp"
self.timeout_msg = ("Code took more than {0} seconds to run. "
"You probably have an infinite loop in your code.").format(SERVER_TIMEOUT)