summaryrefslogtreecommitdiff
path: root/yaksh/cpp_code_evaluator.py
diff options
context:
space:
mode:
authorankitjavalkar2016-09-27 15:08:18 +0530
committerankitjavalkar2016-09-30 10:36:25 +0530
commit6b6e58b06bd49e36edd87a027c08d223571a0c0b (patch)
tree0395d79de3f06204309d933415e38bc215e231f6 /yaksh/cpp_code_evaluator.py
parentac8d6720bc75676e05462cc38ad144d5aedc14e7 (diff)
downloadonline_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/cpp_code_evaluator.py')
-rw-r--r--yaksh/cpp_code_evaluator.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/yaksh/cpp_code_evaluator.py b/yaksh/cpp_code_evaluator.py
index 31b84b2..adef658 100644
--- a/yaksh/cpp_code_evaluator.py
+++ b/yaksh/cpp_code_evaluator.py
@@ -19,9 +19,10 @@ class CppCodeEvaluator(CodeEvaluator):
self.submit_code_path = self.create_submit_code_file('submit.c')
self.compiled_user_answer = None
self.compiled_test_code = None
+ self.user_output_path = ""
+ self.ref_output_path = ""
def teardown(self):
- super(CppCodeEvaluator, self).teardown()
# Delete the created file.
os.remove(self.submit_code_path)
if os.path.exists(self.ref_output_path):
@@ -30,9 +31,11 @@ class CppCodeEvaluator(CodeEvaluator):
os.remove(self.user_output_path)
if self.files:
delete_files(self.files)
+ super(CppCodeEvaluator, self).teardown()
+
def set_file_paths(self):
- user_output_path = os.getcwd() + '/output'
+ user_output_path = os.getcwd() + '/output_file'
ref_output_path = os.getcwd() + '/executable'
return user_output_path, ref_output_path
@@ -105,7 +108,6 @@ class CppCodeEvaluator(CodeEvaluator):
Returns (False, error_msg): If mandatory arguments are not files or
if the required permissions are not given to the file(s).
"""
-
success = False
proc, stdnt_out, stdnt_stderr = self.compiled_user_answer
stdnt_stderr = self._remove_null_substitute_char(stdnt_stderr)
@@ -126,28 +128,28 @@ class CppCodeEvaluator(CodeEvaluator):
if proc.returncode == 0:
success, err = True, "Correct answer"
else:
- err = stdout + "\n" + stderr
+ err = "{0} \n {1}".format(stdout, stderr)
else:
err = "Error:"
try:
error_lines = main_err.splitlines()
for e in error_lines:
if ':' in e:
- err = err + "\n" + e.split(":", 1)[1]
+ err = "{0} \n {1}".format(err, e.split(":", 1)[1])
else:
- err = err + "\n" + e
+ err = "{0} \n {1}".format(err, e)
except:
- err = err + "\n" + main_err
+ err = "{0} \n {1}".format(err, main_err)
else:
err = "Compilation Error:"
try:
error_lines = stdnt_stderr.splitlines()
for e in error_lines:
if ':' in e:
- err = err + "\n" + e.split(":", 1)[1]
+ err = "{0} \n {1}".format(err, e.split(":", 1)[1])
else:
- err = err + "\n" + e
+ err = "{0} \n {1}".format(err, e)
except:
- err = err + "\n" + stdnt_stderr
+ err = "{0} \n {1}".format(err, stdnt_stderr)
return success, err