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_bash_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_bash_evaluation.py')
-rwxr-xr-x | yaksh/evaluator_tests/test_bash_evaluation.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/yaksh/evaluator_tests/test_bash_evaluation.py b/yaksh/evaluator_tests/test_bash_evaluation.py index 01e248f..7fdff48 100755 --- a/yaksh/evaluator_tests/test_bash_evaluation.py +++ b/yaksh/evaluator_tests/test_bash_evaluation.py @@ -1,6 +1,8 @@ from __future__ import absolute_import import unittest import os +import shutil +import tempfile from yaksh.bash_code_evaluator import BashCodeEvaluator from yaksh.bash_stdio_evaluator import BashStdioEvaluator from yaksh.settings import SERVER_TIMEOUT @@ -9,15 +11,23 @@ from textwrap import dedent class BashAssertionEvaluationTestCases(unittest.TestCase): def setUp(self): + with open('/tmp/test.txt', 'wb') as f: + f.write('2'.encode('ascii')) + tmp_in_dir_path = tempfile.mkdtemp() self.test_case_data = [ {"test_case": "bash_files/sample.sh,bash_files/sample.args"} ] - self.in_dir = os.getcwd() + tmp_in_dir_path = tempfile.mkdtemp() + 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): + os.remove('/tmp/test.txt') + shutil.rmtree(self.in_dir) + def test_correct_answer(self): user_answer = ("#!/bin/bash\n[[ $# -eq 2 ]]" " && echo $(( $1 + $2 )) && exit $(( $1 + $2 ))" @@ -56,7 +66,7 @@ class BashAssertionEvaluationTestCases(unittest.TestCase): self.assertEqual(result.get("error"), self.timeout_msg) def test_file_based_assert(self): - self.file_paths = [(os.getcwd()+"/yaksh/test.txt", False)] + self.file_paths = [('/tmp/test.txt', False)] self.test_case_data = [ {"test_case": "bash_files/sample1.sh,bash_files/sample1.args"} ] |