diff options
author | maheshgudi | 2017-02-06 19:59:24 +0530 |
---|---|---|
committer | maheshgudi | 2017-02-06 19:59:24 +0530 |
commit | aa7e5519a4f3809ad42eeaceb2a14b6190c5d345 (patch) | |
tree | 260d4b1dfdb427c427146b2915e4b4e305b82280 /yaksh/evaluator_tests | |
parent | a3886ca604760acee2940daae162940e86b7ac98 (diff) | |
download | online_test-aa7e5519a4f3809ad42eeaceb2a14b6190c5d345.tar.gz online_test-aa7e5519a4f3809ad42eeaceb2a14b6190c5d345.tar.bz2 online_test-aa7e5519a4f3809ad42eeaceb2a14b6190c5d345.zip |
fixed unicode literal bug
Diffstat (limited to 'yaksh/evaluator_tests')
-rw-r--r-- | yaksh/evaluator_tests/test_python_evaluation.py | 65 |
1 files changed, 65 insertions, 0 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): |