summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authorPrabhu Ramachandran2017-02-07 00:17:55 +0530
committerGitHub2017-02-07 00:17:55 +0530
commit01fefb8c7ec31bc6514438eb6b9568a3980ca3de (patch)
tree58757b8835e140e18cf57e3cb118e7a622e5b966 /yaksh
parenta3886ca604760acee2940daae162940e86b7ac98 (diff)
parent7b9a56db9113bf6b7ef9351db8fcda748e9c2be4 (diff)
downloadonline_test-01fefb8c7ec31bc6514438eb6b9568a3980ca3de.tar.gz
online_test-01fefb8c7ec31bc6514438eb6b9568a3980ca3de.tar.bz2
online_test-01fefb8c7ec31bc6514438eb6b9568a3980ca3de.zip
Merge pull request #211 from maheshgudi/fix_unicode_literal_bug
fixed unicode literal bug
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/evaluator_tests/test_python_evaluation.py56
-rw-r--r--yaksh/hook_evaluator.py1
-rw-r--r--yaksh/python_assertion_evaluator.py1
-rw-r--r--yaksh/python_stdio_evaluator.py1
4 files changed, 56 insertions, 3 deletions
diff --git a/yaksh/evaluator_tests/test_python_evaluation.py b/yaksh/evaluator_tests/test_python_evaluation.py
index 82cf4c3..6346941 100644
--- a/yaksh/evaluator_tests/test_python_evaluation.py
+++ b/yaksh/evaluator_tests/test_python_evaluation.py
@@ -1,6 +1,7 @@
from __future__ import unicode_literals
import unittest
import os
+import sys
import tempfile
import shutil
from textwrap import dedent
@@ -449,6 +450,34 @@ class PythonAssertionEvaluationTestCases(EvaluatorBaseTest):
for msg in name_error_msg:
self.assert_correct_output(msg, result.get("error"))
+ def test_unicode_literal_bug(self):
+ # Given
+ user_answer = dedent("""\
+ def strchar(s):
+ a = "should be a string"
+ return type(a)
+ """)
+ test_case_data = [{"test_case_type": "standardtestcase",
+ "test_case": 'assert(strchar("hello")==str)',
+ "weight": 0.0
+ },]
+ kwargs = {
+ 'metadata': {
+ 'user_answer': user_answer,
+ 'file_paths': self.file_paths,
+ 'partial_grading': False,
+ 'language': 'python'
+ },
+ 'test_case_data': test_case_data,
+ }
+ # When
+ grader = Grader(self.in_dir)
+ result = grader.evaluate(kwargs)
+
+ # Then
+ self.assertTrue(result.get("success"))
+
+
class PythonStdIOEvaluationTestCases(EvaluatorBaseTest):
def setUp(self):
with open('/tmp/test.txt', 'wb') as f:
@@ -644,6 +673,33 @@ class PythonStdIOEvaluationTestCases(EvaluatorBaseTest):
self.assertFalse(result.get('success'))
+ def test_unicode_literal_bug(self):
+ # Given
+ user_answer = dedent("""\
+ a = "this should be a string."
+ print(type(a).__name__)
+ """)
+ test_case_data = [{"test_case_type": "stdiobasedtestcase",
+ "expected_input": "",
+ "expected_output": "str",
+ "weight": 0.0
+ }]
+ kwargs = {
+ 'metadata': {
+ 'user_answer': user_answer,
+ 'file_paths': self.file_paths,
+ 'partial_grading': False,
+ 'language': 'python'
+ },
+ 'test_case_data': test_case_data,
+ }
+ # When
+ grader = Grader(self.in_dir)
+ result = grader.evaluate(kwargs)
+ # Then
+ self.assertTrue(result.get("success"))
+
+
class PythonHookEvaluationTestCases(EvaluatorBaseTest):
def setUp(self):
diff --git a/yaksh/hook_evaluator.py b/yaksh/hook_evaluator.py
index 3956da1..2cc4578 100644
--- a/yaksh/hook_evaluator.py
+++ b/yaksh/hook_evaluator.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-from __future__ import unicode_literals
import sys
import traceback
import os
diff --git a/yaksh/python_assertion_evaluator.py b/yaksh/python_assertion_evaluator.py
index daf1afe..11fa101 100644
--- a/yaksh/python_assertion_evaluator.py
+++ b/yaksh/python_assertion_evaluator.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-from __future__ import unicode_literals
import sys
import traceback
import os
diff --git a/yaksh/python_stdio_evaluator.py b/yaksh/python_stdio_evaluator.py
index 27bf69b..a8c797d 100644
--- a/yaksh/python_stdio_evaluator.py
+++ b/yaksh/python_stdio_evaluator.py
@@ -1,4 +1,3 @@
-from __future__ import unicode_literals
import sys
from contextlib import contextmanager