diff options
-rw-r--r-- | yaksh/evaluator_tests/test_python_evaluation.py | 56 | ||||
-rw-r--r-- | yaksh/hook_evaluator.py | 1 | ||||
-rw-r--r-- | yaksh/python_assertion_evaluator.py | 1 | ||||
-rw-r--r-- | yaksh/python_stdio_evaluator.py | 1 |
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 |