diff options
author | ankitjavalkar | 2016-05-02 14:38:13 +0530 |
---|---|---|
committer | ankitjavalkar | 2016-05-09 11:51:06 +0530 |
commit | d953f6f9e62671eeb5d6ea6498475167301dfe91 (patch) | |
tree | ca172e52de5e8dd04e97ce7acfa16ab577ab9d58 /yaksh/evaluator_tests | |
parent | 23b7abd3c1125e4c875e214e4f673c48c4bf4752 (diff) | |
download | online_test-d953f6f9e62671eeb5d6ea6498475167301dfe91.tar.gz online_test-d953f6f9e62671eeb5d6ea6498475167301dfe91.tar.bz2 online_test-d953f6f9e62671eeb5d6ea6498475167301dfe91.zip |
- Fix tests
- Fix minor views.py
- Fix minor errors caused due to conflict resolution, rebasing
- Fix errors in forms, views
- Minor Button label change in addquestion.html
- Add snippet to question
- Remove commented code
Diffstat (limited to 'yaksh/evaluator_tests')
-rw-r--r-- | yaksh/evaluator_tests/test_bash_evaluation.py | 40 | ||||
-rw-r--r-- | yaksh/evaluator_tests/test_code_evaluation.py | 25 | ||||
-rw-r--r-- | yaksh/evaluator_tests/test_java_evaluation.py | 43 | ||||
-rw-r--r-- | yaksh/evaluator_tests/test_python_evaluation.py | 3 | ||||
-rw-r--r-- | yaksh/evaluator_tests/test_scilab_evaluation.py | 20 |
5 files changed, 0 insertions, 131 deletions
diff --git a/yaksh/evaluator_tests/test_bash_evaluation.py b/yaksh/evaluator_tests/test_bash_evaluation.py index 39247f7..7c58c43 100644 --- a/yaksh/evaluator_tests/test_bash_evaluation.py +++ b/yaksh/evaluator_tests/test_bash_evaluation.py @@ -10,15 +10,6 @@ class BashEvaluationTestCases(unittest.TestCase): self.timeout_msg = ("Code took more than {0} seconds to run. " "You probably have an infinite loop in your code.").format(SERVER_TIMEOUT) - # def setUp(self): - # self.language = "bash" - # self.ref_code_path = "bash_files/sample.sh,bash_files/sample.args" - # self.in_dir = "/tmp" - # self.test_case_data = [] - # self.timeout_msg = ("Code took more than {0} seconds to run. " - # "You probably have an infinite loop in your code.").format(SERVER_TIMEOUT) - # self.test = None - def test_correct_answer(self): user_answer = "#!/bin/bash\n[[ $# -eq 2 ]] && echo $(( $1 + $2 )) && exit $(( $1 + $2 ))" get_class = BashCodeEvaluator(self.in_dir) @@ -49,37 +40,6 @@ class BashEvaluationTestCases(unittest.TestCase): self.assertFalse(result.get("success")) self.assertEquals(result.get("error"), self.timeout_msg) - # def test_infinite_loop(self): - # user_answer = "#!/bin/bash\nwhile [ 1 ] ; do echo "" > /dev/null ; done" - # get_class = BashCodeEvaluator(self.test_case_data, self.test, self.language, user_answer, self.ref_code_path, self.in_dir) - # result = get_class.evaluate() - - # self.assertFalse(result.get("success")) - # self.assertEquals(result.get("error"), self.timeout_msg) - - # def test_correct_answer(self): - # user_answer = "#!/bin/bash\n[[ $# -eq 2 ]] && echo $(( $1 + $2 )) && exit $(( $1 + $2 ))" - # get_class = BashCodeEvaluator(self.test_case_data, self.test, self.language, user_answer, self.ref_code_path, self.in_dir) - # result = get_class.evaluate() - - # self.assertTrue(result.get("success")) - # self.assertEqual(result.get("error"), "Correct answer") - - # def test_error(self): - # user_answer = "#!/bin/bash\n[[ $# -eq 2 ]] && echo $(( $1 - $2 )) && exit $(( $1 - $2 ))" - # get_class = BashCodeEvaluator(self.test_case_data, self.test, self.language, user_answer, self.ref_code_path, self.in_dir) - # result = get_class.evaluate() - - # self.assertFalse(result.get("success")) - # self.assertTrue("Error" in result.get("error")) - - # def test_infinite_loop(self): - # user_answer = "#!/bin/bash\nwhile [ 1 ] ; do echo "" > /dev/null ; done" - # get_class = BashCodeEvaluator(self.test_case_data, self.test, self.language, user_answer, self.ref_code_path, self.in_dir) - # result = get_class.evaluate() - - # self.assertFalse(result.get("success")) - # self.assertEquals(result.get("error"), self.timeout_msg) if __name__ == '__main__': unittest.main() diff --git a/yaksh/evaluator_tests/test_code_evaluation.py b/yaksh/evaluator_tests/test_code_evaluation.py index e4f129c..ace6115 100644 --- a/yaksh/evaluator_tests/test_code_evaluation.py +++ b/yaksh/evaluator_tests/test_code_evaluation.py @@ -23,28 +23,3 @@ class RegistryTestCase(unittest.TestCase): if __name__ == '__main__': unittest.main() - - -# import unittest -# import os -# from yaksh import cpp_code_evaluator -# from yaksh.language_registry import _LanguageRegistry, get_registry -# from yaksh.settings import SERVER_TIMEOUT - - -# class RegistryTestCase(unittest.TestCase): -# def setUp(self): -# self.registry_object = get_registry() -# self.language_registry = _LanguageRegistry() - -# def test_set_register(self): -# class_name = getattr(cpp_code_evaluator, 'CppCodeEvaluator') -# self.registry_object.register("c", {"standardtestcase": "cpp_code_evaluator.CppCodeEvaluator"}) -# self.assertEquals(self.registry_object.get_class("c", "standardtestcase"), class_name) - -# def tearDown(self): -# self.registry_object = None - - -# if __name__ == '__main__': -# unittest.main() diff --git a/yaksh/evaluator_tests/test_java_evaluation.py b/yaksh/evaluator_tests/test_java_evaluation.py index eacd62e..76a3fcf 100644 --- a/yaksh/evaluator_tests/test_java_evaluation.py +++ b/yaksh/evaluator_tests/test_java_evaluation.py @@ -57,49 +57,6 @@ class JavaEvaluationTestCases(unittest.TestCase): self.assertFalse(result.get("success")) self.assertEquals(result.get("error"), self.timeout_msg) - # def setUp(self): - # self.language = "java" - # self.ref_code_path = "java_files/main_square.java" - # self.in_dir = "/tmp" - # self.test_case_data = [] - # evaluator.SERVER_TIMEOUT = 9 - # self.timeout_msg = ("Code took more than {0} seconds to run. " - # "You probably have an infinite loop in " - # "your code.").format(evaluator.SERVER_TIMEOUT) - # self.test = None - - # def tearDown(self): - # evaluator.SERVER_TIMEOUT = 2 - - # def test_correct_answer(self): - # user_answer = "class Test {\n\tint square_num(int a) {\n\treturn a*a;\n\t}\n}" - # get_class = JavaCodeEvaluator(self.test_case_data, self.test, - # self.language, user_answer, - # self.ref_code_path, self.in_dir) - # result = get_class.evaluate() - - # self.assertTrue(result.get("success")) - # self.assertEqual(result.get("error"), "Correct answer") - - # def test_error(self): - # user_answer = "class Test {\n\tint square_num(int a) {\n\treturn a*a" - # get_class = JavaCodeEvaluator(self.test_case_data, self.test, - # self.language, user_answer, - # self.ref_code_path, self.in_dir) - # result = get_class.evaluate() - - # self.assertFalse(result.get("success")) - # self.assertTrue("Error" in result.get("error")) - - # def test_infinite_loop(self): - # user_answer = "class Test {\n\tint square_num(int a) {\n\t\twhile(0==0){\n\t\t}\n\t}\n}" - # get_class = JavaCodeEvaluator(self.test_case_data, self.test, - # self.language, user_answer, - # self.ref_code_path, self.in_dir) - # result = get_class.evaluate() - - # self.assertFalse(result.get("success")) - # self.assertEquals(result.get("error"), self.timeout_msg) if __name__ == '__main__': unittest.main() diff --git a/yaksh/evaluator_tests/test_python_evaluation.py b/yaksh/evaluator_tests/test_python_evaluation.py index 39d4723..f6ac0bf 100644 --- a/yaksh/evaluator_tests/test_python_evaluation.py +++ b/yaksh/evaluator_tests/test_python_evaluation.py @@ -16,7 +16,6 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase): "You probably have an infinite loop in your code.").format(SERVER_TIMEOUT) def test_correct_answer(self): - # {u'user_answer': u'def adder(a,b):\r\n return a', u'test_case_data': [u'assert(adder(1,2)==3)']} user_answer = "def add(a,b):\n\treturn a + b" get_class = PythonAssertionEvaluator() kwargs = {'user_answer': user_answer, @@ -156,7 +155,6 @@ class PythonStdoutEvaluationTestCases(unittest.TestCase): "You probably have an infinite loop in your code.").format(SERVER_TIMEOUT) def test_correct_answer(self): - # user_answer = "a = 'Hello'\nb = 'World'\nprint '{0} {1}'.format(a, b)" 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, @@ -197,7 +195,6 @@ class PythonStdoutEvaluationTestCases(unittest.TestCase): self.assertFalse(result.get('success')) self.assertEqual(result.get('error'), 'Incorrect Answer') ->>>>>>> - Add test cases for multiple python evaluators if __name__ == '__main__': unittest.main() diff --git a/yaksh/evaluator_tests/test_scilab_evaluation.py b/yaksh/evaluator_tests/test_scilab_evaluation.py index 928cd7e..24d6740 100644 --- a/yaksh/evaluator_tests/test_scilab_evaluation.py +++ b/yaksh/evaluator_tests/test_scilab_evaluation.py @@ -11,16 +11,6 @@ class ScilabEvaluationTestCases(unittest.TestCase): self.timeout_msg = ("Code took more than {0} seconds to run. " "You probably have an infinite loop in your code.").format(SERVER_TIMEOUT) - # def setUp(self): - # self.language = "scilab" - # self.ref_code_path = "scilab_files/test_add.sce" - # self.in_dir = "/tmp" - # self.test_case_data = [] - # self.timeout_msg = ("Code took more than {0} seconds to run. " - # "You probably have an infinite loop in your code.").format(SERVER_TIMEOUT) - # self.test = None - - def test_correct_answer(self): user_answer = "funcprot(0)\nfunction[c]=add(a,b)\n\tc=a+b;\nendfunction" get_class = ScilabCodeEvaluator(self.in_dir) @@ -31,16 +21,6 @@ class ScilabEvaluationTestCases(unittest.TestCase): self.assertEquals(result.get('error'), "Correct answer") self.assertTrue(result.get('success')) - # def test_correct_answer(self): - # user_answer = "funcprot(0)\nfunction[c]=add(a,b)\n\tc=a+b;\nendfunction" - # get_class = ScilabCodeEvaluator(self.test_case_data, self.test, - # self.language, user_answer, - # self.ref_code_path, self.in_dir) - # result = get_class.evaluate() - - # self.assertTrue(result.get("success")) - # self.assertEqual(result.get("error"), "Correct answer") - def test_error(self): user_answer = "funcprot(0)\nfunction[c]=add(a,b)\n\tc=a+b;\ndis(\tendfunction" get_class = ScilabCodeEvaluator(self.in_dir) |