summaryrefslogtreecommitdiff
path: root/yaksh/python_assertion_evaluator.py
diff options
context:
space:
mode:
authoradityacp2018-04-05 15:30:01 +0530
committeradityacp2018-04-05 15:30:01 +0530
commit032d496c7fa7298a0748885b0f1c8e2c24af67d8 (patch)
tree1cacc6b570ddbc4c8de172ced8e494c8ac655f0d /yaksh/python_assertion_evaluator.py
parentf5c24ccf8b0bde0fe5726728a64f1e3638cf170d (diff)
downloadonline_test-032d496c7fa7298a0748885b0f1c8e2c24af67d8.tar.gz
online_test-032d496c7fa7298a0748885b0f1c8e2c24af67d8.tar.bz2
online_test-032d496c7fa7298a0748885b0f1c8e2c24af67d8.zip
Change error_messages.py, python_assertion_evaluator.py and grader.py
- Pep8 changes - Show code error message along with test case - Add nose in python exec scope
Diffstat (limited to 'yaksh/python_assertion_evaluator.py')
-rw-r--r--yaksh/python_assertion_evaluator.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/yaksh/python_assertion_evaluator.py b/yaksh/python_assertion_evaluator.py
index 440f422..8c7d451 100644
--- a/yaksh/python_assertion_evaluator.py
+++ b/yaksh/python_assertion_evaluator.py
@@ -1,10 +1,6 @@
#!/usr/bin/env python
import sys
import traceback
-import os
-import re
-from os.path import join
-import importlib
# Local imports
from .file_utils import copy_files, delete_files
@@ -43,6 +39,7 @@ class PythonAssertionEvaluator(BaseEvaluator):
submitted = compile(self.user_answer, '<string>', mode='exec')
self.exec_scope = {}
exec(submitted, self.exec_scope)
+ exec("from nose.tools import *", self.exec_scope)
return self.exec_scope
def check_code(self):
@@ -53,18 +50,19 @@ class PythonAssertionEvaluator(BaseEvaluator):
--------
Returns a tuple (success, error, test_case_weight)
- success - Boolean, indicating if code was executed successfully, correctly
+ success - Boolean, indicating if code was executed successfully,
+ correctly
weight - Float, indicating total weight of all successful test cases
error - String, error message if success is false
- returns (True, "Correct answer", 1.0) : If the student script passes all
- test cases/have same output, when compared to the instructor script
+ returns (True, "Correct answer", 1.0) : If the student script passes
+ all test cases/have same output, when compared to the instructor script
returns (False, error_msg, 0.0): If the student script fails a single
test/have dissimilar output, when compared to the instructor script.
- Returns (False, error_msg, 0.0): If mandatory arguments are not files or if
- the required permissions are not given to the file(s).
+ Returns (False, error_msg, 0.0): If mandatory arguments are not files
+ or if the required permissions are not given to the file(s).
"""
success = False
mark_fraction = 0.0