summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--yaksh/evaluator_tests/test_python_evaluation.py65
-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, 65 insertions, 3 deletions
diff --git a/yaksh/evaluator_tests/test_python_evaluation.py b/yaksh/evaluator_tests/test_python_evaluation.py
index 82cf4c3..a463513 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,38 @@ 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 isize(s):
+ import numpy as np
+ size = np.array(s).itemsize
+ return size
+ """)
+ test_case_data = [{"test_case_type": "standardtestcase",
+ "test_case": 'assert(isize("hello")==5)',
+ "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
+ if sys.version[0] < 3:
+ self.assertTrue(result.get("success"))
+ else:
+ self.assertFalse(result.get("success"))
+
+
class PythonStdIOEvaluationTestCases(EvaluatorBaseTest):
def setUp(self):
with open('/tmp/test.txt', 'wb') as f:
@@ -644,6 +677,38 @@ class PythonStdIOEvaluationTestCases(EvaluatorBaseTest):
self.assertFalse(result.get('success'))
+ def test_unicode_literal_bug(self):
+ # Given
+ user_answer = dedent("""\
+ import numpy as np
+ size = np.array(s).itemsize
+ print size
+ """)
+ test_case_data = [{"test_case_type": "stdiobasedtestcase",
+ "expected_input": "",
+ "expected_output": "5",
+ "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
+ if sys.version[0] < 3:
+ self.assertTrue(result.get("success"))
+ else:
+ self.assertFalse(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