summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormahesh2017-11-10 03:00:24 +0530
committermahesh2017-11-10 03:00:24 +0530
commit8f3cd30a5fe553bc8aa701fc76ba8d2a55c4418f (patch)
tree79ba306e0dd23848e3f366d6b89a5f30aabea220
parentcaf37373ec546d53db7caaf8aca9d5550d0ed4ad (diff)
downloadonline_test-8f3cd30a5fe553bc8aa701fc76ba8d2a55c4418f.tar.gz
online_test-8f3cd30a5fe553bc8aa701fc76ba8d2a55c4418f.tar.bz2
online_test-8f3cd30a5fe553bc8aa701fc76ba8d2a55c4418f.zip
No tracebacks if longer than 5 lines.
- Tracebacks with more than 5 lines will not be shown. - Remove unnecessary imports. - PEP8 change.
-rw-r--r--yaksh/error_messages.py12
-rw-r--r--yaksh/python_assertion_evaluator.py3
-rw-r--r--yaksh/templates/exam.html4
3 files changed, 8 insertions, 11 deletions
diff --git a/yaksh/error_messages.py b/yaksh/error_messages.py
index 25b690b..77bb1c9 100644
--- a/yaksh/error_messages.py
+++ b/yaksh/error_messages.py
@@ -9,8 +9,8 @@ def prettify_exceptions(exception, message, traceback=None, testcase=None):
"traceback": traceback,
"message": message
}
- if exception == "RecursionError":
- err["traceback"] = None
+ if traceback and traceback.count('\n') > 6:
+ err["traceback"] = None
if exception == 'AssertionError':
value = ("Expected answer from the"
+ " test case did not match the output")
@@ -32,11 +32,11 @@ def _get_incorrect_user_lines(exp_lines, user_lines):
def compare_outputs(expected_output, user_output, given_input=None):
given_lines = user_output.splitlines()
exp_lines = expected_output.splitlines()
- msg = {"given_input":given_input,
+ msg = {"type": "stdio",
+ "given_input": given_input,
"expected_output": exp_lines,
- "user_output":given_lines,
- "type": "stdio"
- }
+ "user_output": given_lines
+ }
ng = len(given_lines)
ne = len(exp_lines)
err_line_numbers = _get_incorrect_user_lines(exp_lines, given_lines)
diff --git a/yaksh/python_assertion_evaluator.py b/yaksh/python_assertion_evaluator.py
index 8c24e24..440f422 100644
--- a/yaksh/python_assertion_evaluator.py
+++ b/yaksh/python_assertion_evaluator.py
@@ -4,7 +4,6 @@ import traceback
import os
import re
from os.path import join
-from textwrap import dedent
import importlib
# Local imports
@@ -70,7 +69,6 @@ class PythonAssertionEvaluator(BaseEvaluator):
success = False
mark_fraction = 0.0
try:
- tb = None
_tests = compile(self.test_case, '<string>', mode='exec')
exec(_tests, self.exec_scope)
except TimeoutException:
@@ -89,5 +87,4 @@ class PythonAssertionEvaluator(BaseEvaluator):
success = True
err = None
mark_fraction = 1.0 if self.partial_grading else 0.0
- del tb
return success, err, mark_fraction
diff --git a/yaksh/templates/exam.html b/yaksh/templates/exam.html
index 1d7af9c..1cd3964 100644
--- a/yaksh/templates/exam.html
+++ b/yaksh/templates/exam.html
@@ -86,14 +86,14 @@
<div class="row" id="error_panel">
{% for error in error_message %}
<div class="panel panel-danger">
- <div class="panel-heading">Testcase No. {{ forloop.counter }}</div>
+ <div class="panel-heading">Error No. {{ forloop.counter }}</div>
<div class="panel-body">
<div class="well well-sm">
{% if not error.type %}
<pre><code> {{error|safe}} </code></pre>
{% elif error.type == 'assertion' %}
{% if error.test_case %}
- <strong> We tried you code with the following test case:</strong><br/></br>
+ <strong> We tried your code with the following test case:</strong><br/></br>
<pre><code><strong style="color:#d9534f">{{error.test_case}}</strong></code></pre>
{% endif %}
<p> <b>The following error took place: </b></p>