summaryrefslogtreecommitdiff
path: root/yaksh/stdio_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/stdio_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/stdio_evaluator.py')
-rw-r--r--yaksh/stdio_evaluator.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/yaksh/stdio_evaluator.py b/yaksh/stdio_evaluator.py
index f1def95..b5924ff 100644
--- a/yaksh/stdio_evaluator.py
+++ b/yaksh/stdio_evaluator.py
@@ -15,8 +15,10 @@ class StdIOEvaluator(CodeEvaluator):
def evaluate_stdio(self, user_answer, proc, expected_input, expected_output):
success = False
ip = expected_input.replace(",", " ")
- print (type(expected_input), type(ip))
- user_output, output_err = proc.communicate(input='{0}\n'.format(ip))
+ encoded_input = '{0}\n'.format(ip).encode('utf-8')
+ user_output_bytes, output_err_bytes = proc.communicate(encoded_input)
+ user_output = user_output_bytes.decode('utf-8')
+ output_err = output_err_bytes.decode('utf-8')
expected_output = expected_output.replace("\r", "")
if not expected_input:
error_msg = "Expected Output is {0} ".\
@@ -31,5 +33,5 @@ class StdIOEvaluator(CodeEvaluator):
err = " Incorrect answer\n" + error_msg +\
"\n Your output is {0}".format(repr(user_output))
else:
- err = "Error:"+"\n"+output_err
+ err = "Error:\n {0}".format(output_err)
return success, err