diff options
author | ankitjavalkar | 2016-09-27 15:08:18 +0530 |
---|---|---|
committer | ankitjavalkar | 2016-09-30 10:36:25 +0530 |
commit | 6b6e58b06bd49e36edd87a027c08d223571a0c0b (patch) | |
tree | 0395d79de3f06204309d933415e38bc215e231f6 /yaksh/evaluator_tests/test_scilab_evaluation.py | |
parent | ac8d6720bc75676e05462cc38ad144d5aedc14e7 (diff) | |
download | online_test-6b6e58b06bd49e36edd87a027c08d223571a0c0b.tar.gz online_test-6b6e58b06bd49e36edd87a027c08d223571a0c0b.tar.bz2 online_test-6b6e58b06bd49e36edd87a027c08d223571a0c0b.zip |
Fix test cases and corresponding changes in evaluators for Python 2/3 compatibility
Diffstat (limited to 'yaksh/evaluator_tests/test_scilab_evaluation.py')
-rw-r--r-- | yaksh/evaluator_tests/test_scilab_evaluation.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/yaksh/evaluator_tests/test_scilab_evaluation.py b/yaksh/evaluator_tests/test_scilab_evaluation.py index f1b29dd..0bb7bfd 100644 --- a/yaksh/evaluator_tests/test_scilab_evaluation.py +++ b/yaksh/evaluator_tests/test_scilab_evaluation.py @@ -1,19 +1,26 @@ from __future__ import absolute_import import unittest import os +import shutil +import tempfile + from yaksh import code_evaluator as evaluator from yaksh.scilab_code_evaluator import ScilabCodeEvaluator from yaksh.settings import SERVER_TIMEOUT class ScilabEvaluationTestCases(unittest.TestCase): def setUp(self): + tmp_in_dir_path = tempfile.mkdtemp() self.test_case_data = [{"test_case": "scilab_files/test_add.sce"}] - self.in_dir = os.getcwd() + self.in_dir = tmp_in_dir_path self.timeout_msg = ("Code took more than {0} seconds to run. " "You probably have an infinite loop" " in your code.").format(SERVER_TIMEOUT) self.file_paths = None + def tearDown(self): + shutil.rmtree(self.in_dir) + def test_correct_answer(self): user_answer = ("funcprot(0)\nfunction[c]=add(a,b)" "\n\tc=a+b;\nendfunction") @@ -36,7 +43,7 @@ class ScilabEvaluationTestCases(unittest.TestCase): } result = get_class.evaluate(**kwargs) self.assertFalse(result.get("success")) - self.assertTrue("error" in result.get("error")) + self.assertTrue('error' in result.get("error")) def test_incorrect_answer(self): @@ -48,9 +55,10 @@ class ScilabEvaluationTestCases(unittest.TestCase): 'file_paths': self.file_paths } result = get_class.evaluate(**kwargs) + lines_of_error = len(result.get('error').splitlines()) self.assertFalse(result.get('success')) self.assertIn("Message", result.get('error')) - self.assertTrue(result.get('error').splitlines > 1) + self.assertTrue(lines_of_error > 1) def test_infinite_loop(self): user_answer = ("funcprot(0)\nfunction[c]=add(a,b)" |