diff options
author | ankitjavalkar | 2016-12-20 12:42:44 +0530 |
---|---|---|
committer | ankitjavalkar | 2016-12-20 15:31:22 +0530 |
commit | bf5b4e7607bae0b81ceeb99e8bf5d750433e92e8 (patch) | |
tree | c0d4a002bba428269c2f7ba62eb68d24b8cbec5f /yaksh/evaluator_tests | |
parent | 798d36aa12e22928e884668ae5c80a25d48393ea (diff) | |
download | online_test-bf5b4e7607bae0b81ceeb99e8bf5d750433e92e8.tar.gz online_test-bf5b4e7607bae0b81ceeb99e8bf5d750433e92e8.tar.bz2 online_test-bf5b4e7607bae0b81ceeb99e8bf5d750433e92e8.zip |
Fix errors and rename resources
- code_evaluator module and class renamed to grader
- Test cases fixed
- Comments removed
- weight variable renamed to mark
Diffstat (limited to 'yaksh/evaluator_tests')
-rw-r--r-- | yaksh/evaluator_tests/test_bash_evaluation.py | 38 | ||||
-rw-r--r-- | yaksh/evaluator_tests/test_c_cpp_evaluation.py | 82 | ||||
-rw-r--r-- | yaksh/evaluator_tests/test_code_evaluation.py | 4 | ||||
-rw-r--r-- | yaksh/evaluator_tests/test_java_evaluation.py | 83 | ||||
-rw-r--r-- | yaksh/evaluator_tests/test_python_evaluation.py | 80 | ||||
-rw-r--r-- | yaksh/evaluator_tests/test_scilab_evaluation.py | 30 |
6 files changed, 158 insertions, 159 deletions
diff --git a/yaksh/evaluator_tests/test_bash_evaluation.py b/yaksh/evaluator_tests/test_bash_evaluation.py index 142d7f0..06a56e4 100644 --- a/yaksh/evaluator_tests/test_bash_evaluation.py +++ b/yaksh/evaluator_tests/test_bash_evaluation.py @@ -3,9 +3,9 @@ import unittest import os import shutil import tempfile -from yaksh.code_evaluator import CodeEvaluator +from yaksh.grader import Grader from yaksh.bash_code_evaluator import BashCodeEvaluator -from yaksh.bash_stdio_evaluator import BashStdioEvaluator +from yaksh.bash_stdio_evaluator import BashStdIOEvaluator from yaksh.settings import SERVER_TIMEOUT from textwrap import dedent @@ -44,8 +44,8 @@ class BashAssertionEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertTrue(result.get('success')) self.assertEqual(result.get('error'), "Correct answer\n") @@ -63,8 +63,8 @@ class BashAssertionEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertFalse(result.get("success")) self.assertTrue("Error" in result.get("error")) @@ -82,8 +82,8 @@ class BashAssertionEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertFalse(result.get("success")) self.assertEqual(result.get("error"), self.timeout_msg) @@ -107,13 +107,13 @@ class BashAssertionEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertTrue(result.get("success")) self.assertEqual(result.get("error"), "Correct answer\n") -class BashStdioEvaluationTestCases(unittest.TestCase): +class BashStdIOEvaluationTestCases(unittest.TestCase): def setUp(self): self.in_dir = tempfile.mkdtemp() self.timeout_msg = ("Code took more than {0} seconds to run. " @@ -144,8 +144,8 @@ class BashStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertEqual(result.get('error'), "Correct answer\n") self.assertTrue(result.get('success')) @@ -174,8 +174,8 @@ class BashStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertEqual(result.get('error'), "Correct answer\n") self.assertTrue(result.get('success')) @@ -202,8 +202,8 @@ class BashStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertIn("Incorrect", result.get('error')) self.assertFalse(result.get('success')) @@ -229,8 +229,8 @@ class BashStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertEqual(result.get('error'), "Correct answer\n") self.assertTrue(result.get('success')) diff --git a/yaksh/evaluator_tests/test_c_cpp_evaluation.py b/yaksh/evaluator_tests/test_c_cpp_evaluation.py index 4dd6a2f..dc6fdc9 100644 --- a/yaksh/evaluator_tests/test_c_cpp_evaluation.py +++ b/yaksh/evaluator_tests/test_c_cpp_evaluation.py @@ -6,9 +6,9 @@ import tempfile from textwrap import dedent # Local import -from yaksh.code_evaluator import CodeEvaluator +from yaksh.grader import Grader from yaksh.cpp_code_evaluator import CppCodeEvaluator -from yaksh.cpp_stdio_evaluator import CppStdioEvaluator +from yaksh.cpp_stdio_evaluator import CppStdIOEvaluator from yaksh.settings import SERVER_TIMEOUT @@ -44,8 +44,8 @@ class CAssertionEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertTrue(result.get('success')) self.assertEqual(result.get('error'), "Correct answer\n") @@ -62,8 +62,8 @@ class CAssertionEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) lines_of_error = len(result.get('error').splitlines()) self.assertFalse(result.get('success')) @@ -82,8 +82,8 @@ class CAssertionEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertFalse(result.get("success")) self.assertTrue("Compilation Error" in result.get("error")) @@ -100,8 +100,8 @@ class CAssertionEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertFalse(result.get("success")) self.assertEqual(result.get("error"), self.timeout_msg) @@ -134,13 +134,13 @@ class CAssertionEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertTrue(result.get('success')) self.assertEqual(result.get('error'), "Correct answer\n") -class CppStdioEvaluationTestCases(unittest.TestCase): +class CppStdIOEvaluationTestCases(unittest.TestCase): def setUp(self): self.test_case_data = [{'expected_output': '11', 'expected_input': '5\n6', @@ -171,8 +171,8 @@ class CppStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertEqual(result.get('error'), "Correct answer\n") self.assertTrue(result.get('success')) @@ -202,8 +202,8 @@ class CppStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertEqual(result.get('error'), "Correct answer\n") self.assertTrue(result.get('success')) @@ -231,8 +231,8 @@ class CppStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertEqual(result.get('error'), "Correct answer\n") self.assertTrue(result.get('success')) @@ -254,8 +254,8 @@ class CppStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) lines_of_error = len(result.get('error').splitlines()) self.assertFalse(result.get('success')) @@ -279,8 +279,8 @@ class CppStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertFalse(result.get("success")) self.assertTrue("Compilation Error" in result.get("error")) @@ -302,8 +302,8 @@ class CppStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertFalse(result.get("success")) self.assertEqual(result.get("error"), self.timeout_msg) @@ -330,8 +330,8 @@ class CppStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertEqual(result.get('error'), "Correct answer\n") self.assertTrue(result.get('success')) @@ -355,8 +355,8 @@ class CppStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertEqual(result.get('error'), "Correct answer\n") self.assertTrue(result.get('success')) @@ -387,8 +387,8 @@ class CppStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertEqual(result.get('error'), "Correct answer\n") self.assertTrue(result.get('success')) @@ -417,8 +417,8 @@ class CppStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertEqual(result.get('error'), "Correct answer\n") self.assertTrue(result.get('success')) @@ -441,8 +441,8 @@ class CppStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) lines_of_error = len(result.get('error').splitlines()) self.assertFalse(result.get('success')) @@ -467,8 +467,8 @@ class CppStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertFalse(result.get("success")) self.assertTrue("Compilation Error" in result.get("error")) @@ -491,8 +491,8 @@ class CppStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertFalse(result.get("success")) self.assertEqual(result.get("error"), self.timeout_msg) @@ -520,8 +520,8 @@ class CppStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertEqual(result.get('error'), "Correct answer\n") self.assertTrue(result.get('success')) diff --git a/yaksh/evaluator_tests/test_code_evaluation.py b/yaksh/evaluator_tests/test_code_evaluation.py index f664200..cb783b0 100644 --- a/yaksh/evaluator_tests/test_code_evaluation.py +++ b/yaksh/evaluator_tests/test_code_evaluation.py @@ -14,7 +14,7 @@ class RegistryTestCase(unittest.TestCase): ".PythonAssertionEvaluator" ) stdio_evaluator_path = ("yaksh.python_stdio_evaluator." - "PythonStdioEvaluator" + "PythonStdIOEvaluator" ) code_evaluators['python'] = \ {"standardtestcase": assertion_evaluator_path, @@ -29,7 +29,7 @@ class RegistryTestCase(unittest.TestCase): ".PythonAssertionEvaluator" ) stdio_evaluator_path = ("yaksh.python_stdio_evaluator." - "PythonStdioEvaluator" + "PythonStdIOEvaluator" ) class_name = getattr(python_assertion_evaluator, 'PythonAssertionEvaluator' diff --git a/yaksh/evaluator_tests/test_java_evaluation.py b/yaksh/evaluator_tests/test_java_evaluation.py index 246a3e5..36eb6a5 100644 --- a/yaksh/evaluator_tests/test_java_evaluation.py +++ b/yaksh/evaluator_tests/test_java_evaluation.py @@ -3,13 +3,14 @@ import unittest import os import shutil import tempfile -from yaksh import code_evaluator -from yaksh.code_evaluator import CodeEvaluator -from yaksh.java_code_evaluator import JavaCodeEvaluator -from yaksh.java_stdio_evaluator import JavaStdioEvaluator -from yaksh.settings import SERVER_TIMEOUT from textwrap import dedent +# Local Import +from yaksh import grader as gd +from yaksh.grader import Grader +from yaksh.java_code_evaluator import JavaCodeEvaluator +from yaksh.java_stdio_evaluator import JavaStdIOEvaluator + class JavaAssertionEvaluationTestCases(unittest.TestCase): def setUp(self): @@ -23,14 +24,15 @@ class JavaAssertionEvaluationTestCases(unittest.TestCase): } ] self.in_dir = tmp_in_dir_path - code_evaluator.SERVER_TIMEOUT = 9 + self.file_paths = None + gd.SERVER_TIMEOUT = 9 self.timeout_msg = ("Code took more than {0} seconds to run. " "You probably have an infinite loop in" - " your code.").format(code_evaluator.SERVER_TIMEOUT) - self.file_paths = None + " your code.").format(gd.SERVER_TIMEOUT) + def tearDown(self): - code_evaluator.SERVER_TIMEOUT = 4 + gd.SERVER_TIMEOUT = 4 os.remove('/tmp/test.txt') shutil.rmtree(self.in_dir) @@ -46,8 +48,8 @@ class JavaAssertionEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertEqual(result.get('error'), "Correct answer\n") self.assertTrue(result.get('success')) @@ -64,8 +66,8 @@ class JavaAssertionEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertFalse(result.get('success')) lines_of_error = len(result.get('error').splitlines()) @@ -85,8 +87,8 @@ class JavaAssertionEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertFalse(result.get("success")) self.assertTrue("Error" in result.get("error")) @@ -103,8 +105,8 @@ class JavaAssertionEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertFalse(result.get("success")) self.assertEqual(result.get("error"), self.timeout_msg) @@ -145,13 +147,13 @@ class JavaAssertionEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertTrue(result.get("success")) self.assertEqual(result.get("error"), "Correct answer\n") -class JavaStdioEvaluationTestCases(unittest.TestCase): +class JavaStdIOEvaluationTestCases(unittest.TestCase): def setUp(self): with open('/tmp/test.txt', 'wb') as f: f.write('2'.encode('ascii')) @@ -162,14 +164,14 @@ class JavaStdioEvaluationTestCases(unittest.TestCase): 'test_case_type': 'stdiobasedtestcase', 'weight': 0.0 }] - code_evaluator.SERVER_TIMEOUT = 4 + self.file_paths = None + gd.SERVER_TIMEOUT = 9 self.timeout_msg = ("Code took more than {0} seconds to run. " "You probably have an infinite loop in" - " your code.").format(code_evaluator.SERVER_TIMEOUT) - self.file_paths = None + " your code.").format(gd.SERVER_TIMEOUT) def tearDown(self): - code_evaluator.SERVER_TIMEOUT = 4 + gd.SERVER_TIMEOUT = 4 os.remove('/tmp/test.txt') shutil.rmtree(self.in_dir) @@ -193,8 +195,8 @@ class JavaStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertEqual(result.get('error'), "Correct answer\n") self.assertTrue(result.get('success')) @@ -225,8 +227,8 @@ class JavaStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertEqual(result.get('error'), "Correct answer\n") self.assertTrue(result.get('success')) @@ -251,8 +253,8 @@ class JavaStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) lines_of_error = len(result.get('error').splitlines()) self.assertFalse(result.get('success')) @@ -275,14 +277,13 @@ class JavaStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertFalse(result.get("success")) self.assertTrue("Compilation Error" in result.get("error")) def test_infinite_loop(self): - user_answer = dedent(""" class Test {public static void main(String[] args){ @@ -300,8 +301,8 @@ class JavaStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertFalse(result.get("success")) self.assertEqual(result.get("error"), self.timeout_msg) @@ -329,8 +330,8 @@ class JavaStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertEqual(result.get('error'), "Correct answer\n") self.assertTrue(result.get('success')) @@ -360,8 +361,8 @@ class JavaStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertEqual(result.get('error'), "Correct answer\n") self.assertTrue(result.get('success')) @@ -401,8 +402,8 @@ class JavaStdioEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertTrue(result.get("success")) self.assertEqual(result.get("error"), "Correct answer\n") diff --git a/yaksh/evaluator_tests/test_python_evaluation.py b/yaksh/evaluator_tests/test_python_evaluation.py index 29336d6..e638049 100644 --- a/yaksh/evaluator_tests/test_python_evaluation.py +++ b/yaksh/evaluator_tests/test_python_evaluation.py @@ -6,9 +6,9 @@ import shutil from textwrap import dedent # Local import -from yaksh.code_evaluator import CodeEvaluator +from yaksh.grader import Grader from yaksh.python_assertion_evaluator import PythonAssertionEvaluator -from yaksh.python_stdio_evaluator import PythonStdioEvaluator +from yaksh.python_stdio_evaluator import PythonStdIOEvaluator from yaksh.settings import SERVER_TIMEOUT class PythonAssertionEvaluationTestCases(unittest.TestCase): @@ -44,8 +44,8 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase): } # When - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) # Then self.assertTrue(result.get('success')) @@ -65,8 +65,8 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase): } # When - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) # Then self.assertFalse(result.get('success')) @@ -98,8 +98,8 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase): } # When - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) # Then self.assertFalse(result.get('success')) @@ -125,8 +125,8 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase): } # When - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) # Then self.assertFalse(result.get('success')) @@ -157,8 +157,8 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase): } # When - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) err = result.get("error").splitlines() # Then @@ -191,8 +191,8 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase): } # When - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) err = result.get("error").splitlines() # Then @@ -222,8 +222,8 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase): } # When - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) err = result.get("error").splitlines() # Then @@ -254,8 +254,8 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase): } # When - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) err = result.get("error").splitlines() # Then @@ -286,8 +286,8 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase): } # When - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) err = result.get("error").splitlines() # Then @@ -321,8 +321,8 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase): } # When - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) err = result.get("error").splitlines() # Then @@ -352,8 +352,8 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase): } # When - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) # Then self.assertIn("Correct answer", result.get('error')) @@ -389,8 +389,8 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase): } # When - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) err = result.get("error").splitlines() # Then @@ -430,8 +430,8 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase): } # When - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) err = result.get("error").splitlines() # Then @@ -471,8 +471,8 @@ class PythonStdIOEvaluationTestCases(unittest.TestCase): } # When - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) # Then self.assertTrue(result.get('success')) @@ -505,8 +505,8 @@ class PythonStdIOEvaluationTestCases(unittest.TestCase): } # When - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) # Then self.assertTrue(result.get('success')) @@ -537,8 +537,8 @@ class PythonStdIOEvaluationTestCases(unittest.TestCase): } # When - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) # Then self.assertTrue(result.get('success')) @@ -567,8 +567,8 @@ class PythonStdIOEvaluationTestCases(unittest.TestCase): } # When - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) # Then self.assertFalse(result.get('success')) @@ -599,8 +599,8 @@ class PythonStdIOEvaluationTestCases(unittest.TestCase): } # When - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) # Then self.assertEqual(result.get('error'), "Correct answer\n") @@ -628,8 +628,8 @@ class PythonStdIOEvaluationTestCases(unittest.TestCase): } # When - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) # Then self.assertEqual(result.get('error'), timeout_msg) diff --git a/yaksh/evaluator_tests/test_scilab_evaluation.py b/yaksh/evaluator_tests/test_scilab_evaluation.py index e879cda..0275ee8 100644 --- a/yaksh/evaluator_tests/test_scilab_evaluation.py +++ b/yaksh/evaluator_tests/test_scilab_evaluation.py @@ -4,10 +4,9 @@ import os import shutil import tempfile -from yaksh import code_evaluator -from yaksh.code_evaluator import CodeEvaluator +from yaksh import grader as gd +from yaksh.grader import Grader from yaksh.scilab_code_evaluator import ScilabCodeEvaluator -from yaksh.settings import SERVER_TIMEOUT class ScilabEvaluationTestCases(unittest.TestCase): def setUp(self): @@ -17,14 +16,14 @@ class ScilabEvaluationTestCases(unittest.TestCase): "weight": 0.0 }] self.in_dir = tmp_in_dir_path + self.file_paths = None + gd.SERVER_TIMEOUT = 9 self.timeout_msg = ("Code took more than {0} seconds to run. " "You probably have an infinite loop" - " in your code.").format(SERVER_TIMEOUT) - code_evaluator.SERVER_TIMEOUT = 9 - self.file_paths = None + " in your code.").format(gd.SERVER_TIMEOUT) def tearDown(self): - code_evaluator.SERVER_TIMEOUT = 4 + gd.SERVER_TIMEOUT = 4 shutil.rmtree(self.in_dir) def test_correct_answer(self): @@ -40,8 +39,8 @@ class ScilabEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertEqual(result.get('error'), "Correct answer\n") self.assertTrue(result.get('success')) @@ -59,8 +58,8 @@ class ScilabEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertFalse(result.get("success")) self.assertTrue('error' in result.get("error")) @@ -79,8 +78,8 @@ class ScilabEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) lines_of_error = len(result.get('error').splitlines()) self.assertFalse(result.get('success')) @@ -88,7 +87,6 @@ class ScilabEvaluationTestCases(unittest.TestCase): self.assertTrue(lines_of_error > 1) def test_infinite_loop(self): - code_evaluator.SERVER_TIMEOUT = 4 user_answer = ("funcprot(0)\nfunction[c]=add(a,b)" "\n\tc=a;\nwhile(1==1)\nend\nendfunction") kwargs = { @@ -101,8 +99,8 @@ class ScilabEvaluationTestCases(unittest.TestCase): 'test_case_data': self.test_case_data, } - evaluator = CodeEvaluator(self.in_dir) - result = evaluator.evaluate(kwargs) + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) self.assertFalse(result.get("success")) self.assertEqual(result.get("error"), self.timeout_msg) |