summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authormaheshgudi2017-10-09 17:32:11 +0530
committermaheshgudi2017-10-09 17:32:11 +0530
commitdc2d4c0654d6d7c23ccf7b10aa985cc6afe4f4a7 (patch)
treea2ec215983e5d74defc50fcd2312b2dd4063d358 /yaksh
parent324311cc94c1b7eb88c63aaa4d72cf2f486bd296 (diff)
downloadonline_test-dc2d4c0654d6d7c23ccf7b10aa985cc6afe4f4a7.tar.gz
online_test-dc2d4c0654d6d7c23ccf7b10aa985cc6afe4f4a7.tar.bz2
online_test-dc2d4c0654d6d7c23ccf7b10aa985cc6afe4f4a7.zip
Fix expected input as None bug
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/evaluator_tests/test_bash_evaluation.py1
-rw-r--r--yaksh/evaluator_tests/test_c_cpp_evaluation.py1
-rw-r--r--yaksh/evaluator_tests/test_java_evaluation.py1
-rw-r--r--yaksh/stdio_evaluator.py11
4 files changed, 8 insertions, 6 deletions
diff --git a/yaksh/evaluator_tests/test_bash_evaluation.py b/yaksh/evaluator_tests/test_bash_evaluation.py
index 6e7410e..2faa7bf 100644
--- a/yaksh/evaluator_tests/test_bash_evaluation.py
+++ b/yaksh/evaluator_tests/test_bash_evaluation.py
@@ -255,7 +255,6 @@ class BashStdIOEvaluationTestCases(EvaluatorBaseTest):
"""
)
test_case_data = [{'expected_output': '10',
- 'expected_input': '',
'test_case_type': 'stdiobasedtestcase',
'weight': 0.0
}]
diff --git a/yaksh/evaluator_tests/test_c_cpp_evaluation.py b/yaksh/evaluator_tests/test_c_cpp_evaluation.py
index 5ff4e4c..0898b3f 100644
--- a/yaksh/evaluator_tests/test_c_cpp_evaluation.py
+++ b/yaksh/evaluator_tests/test_c_cpp_evaluation.py
@@ -415,7 +415,6 @@ class CppStdIOEvaluationTestCases(EvaluatorBaseTest):
def test_only_stdout(self):
# Given
self.test_case_data = [{'expected_output': '11',
- 'expected_input': '',
'weight': 0.0,
'test_case_type': 'stdiobasedtestcase',
}]
diff --git a/yaksh/evaluator_tests/test_java_evaluation.py b/yaksh/evaluator_tests/test_java_evaluation.py
index c733586..5ddf8cd 100644
--- a/yaksh/evaluator_tests/test_java_evaluation.py
+++ b/yaksh/evaluator_tests/test_java_evaluation.py
@@ -414,7 +414,6 @@ class JavaStdIOEvaluationTestCases(EvaluatorBaseTest):
def test_only_stdout(self):
# Given
self.test_case_data = [{'expected_output': '11',
- 'expected_input': '',
'test_case_type': 'stdiobasedtestcase',
'weight': 0.0
}]
diff --git a/yaksh/stdio_evaluator.py b/yaksh/stdio_evaluator.py
index 932ae7e..5e4ce18 100644
--- a/yaksh/stdio_evaluator.py
+++ b/yaksh/stdio_evaluator.py
@@ -11,10 +11,15 @@ from .compare_stdio import compare_outputs
class StdIOEvaluator(BaseEvaluator):
def evaluate_stdio(self, user_answer, proc, expected_input, expected_output):
success = False
- ip = expected_input.replace(",", " ")
- encoded_input = '{0}\n'.format(ip).encode('utf-8')
try:
- user_output_bytes, output_err_bytes = proc.communicate(encoded_input)
+ if expected_input:
+ ip = expected_input.replace(",", " ")
+ encoded_input = '{0}\n'.format(ip).encode('utf-8')
+ user_output_bytes, output_err_bytes = proc.communicate(
+ encoded_input
+ )
+ else:
+ user_output_bytes, output_err_bytes = proc.communicate()
user_output = user_output_bytes.decode('utf-8')
output_err = output_err_bytes.decode('utf-8')
except TimeoutException: