diff options
author | Prabhu Ramachandran | 2017-11-10 17:50:48 +0530 |
---|---|---|
committer | GitHub | 2017-11-10 17:50:48 +0530 |
commit | 96f8e0af5b39338741c758de918e32e02b95f0c8 (patch) | |
tree | 80fb17501e7995ed3abb34ac3b0d62dd8decc560 /yaksh/grader.py | |
parent | cfcb2ed39c724639fe17338e29e327d08ae641b2 (diff) | |
parent | 95f862caee8ca6077ee8f9a8fc88d9ca44db1cdf (diff) | |
download | online_test-96f8e0af5b39338741c758de918e32e02b95f0c8.tar.gz online_test-96f8e0af5b39338741c758de918e32e02b95f0c8.tar.bz2 online_test-96f8e0af5b39338741c758de918e32e02b95f0c8.zip |
Merge pull request #380 from maheshgudi/beautify_assertions
Prettify assertion error output
Diffstat (limited to 'yaksh/grader.py')
-rw-r--r-- | yaksh/grader.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/yaksh/grader.py b/yaksh/grader.py index a9a3738..38cce8d 100644 --- a/yaksh/grader.py +++ b/yaksh/grader.py @@ -21,7 +21,7 @@ except ImportError: # Local imports from .settings import SERVER_TIMEOUT from .language_registry import create_evaluator_instance - +from .error_messages import prettify_exceptions MY_DIR = abspath(dirname(__file__)) registry = None @@ -141,7 +141,8 @@ class Grader(object): for idx, test_case_instance in enumerate(test_case_instances): test_case_success = False test_case_instance.compile_code() - test_case_success, err, mark_fraction = test_case_instance.check_code() + eval_result = test_case_instance.check_code() + test_case_success, err, mark_fraction = eval_result if test_case_success: weight += mark_fraction * test_case_instance.weight else: @@ -154,16 +155,20 @@ class Grader(object): test_case_instance.teardown() except TimeoutException: - error.append(self.timeout_msg) - except OSError: - msg = traceback.format_exc(limit=0) - error.append("Error: {0}".format(msg)) + error.append(prettify_exceptions("TimeoutException", + self.timeout_msg + ) + ) except Exception: exc_type, exc_value, exc_tb = sys.exc_info() tb_list = traceback.format_exception(exc_type, exc_value, exc_tb) if len(tb_list) > 2: del tb_list[1:3] - error.append("Error: {0}".format("".join(tb_list))) + error.append(prettify_exceptions(exc_type.__name__, + str(exc_value), + "".join(tb_list), + ) + ) finally: # Set back any original signal handler. set_original_signal_handler(prev_handler) |