Skip to content

Commit

Permalink
Release 0.4.8 - Better error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
heynemann committed May 2, 2011
1 parent b762ba2 commit e84e5e9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
12 changes: 12 additions & 0 deletions pyvows/reporting.py
Expand Up @@ -77,8 +77,20 @@ def print_context(self, name, context):
print "%s%s" % (self.tab * (self.indent + 2), Fore.RED + str(exc_value) + Fore.RESET)
print
print "%s%s" % (self.tab * (self.indent + 2), error_msg)

if isinstance(test['topic'], Exception):
print
print "%s%s" % (self.tab * (self.indent + 3), Fore.RED + 'Original Exception' + Fore.RESET)
print
exc_type, exc_value, exc_traceback = test['context_instance'].topic_error
print "%s%s" % (self.tab * (self.indent + 3), Fore.RED + str(exc_value) + Fore.RESET)
error_msg = traceback.format_exception(exc_type, exc_value, exc_traceback)
error_msg = (self.tab * (self.indent + 3)).join(error_msg)
print "%s%s" % (self.tab * (self.indent + 3), error_msg)

if 'file' in test:
print "%s%s" % (self.tab * (self.indent + 2), Fore.RED + "(found in %s at line %s)" % (test['file'], test['lineno']) + Fore.RESET)

for name, context in context['contexts'].iteritems():
self.print_context(name, context)

Expand Down
8 changes: 6 additions & 2 deletions pyvows/runner.py
Expand Up @@ -60,8 +60,10 @@ def async_run_context(self, context_col, name, context, parent):
topic_func = getattr(context_instance, 'topic')
topic_list = self.get_topics_for(topic_func, context_instance)
topic = topic_func(*topic_list)
except Exception, err:
topic = err
except Exception:
exc_type, exc_value, exc_traceback = sys.exc_info()
topic = exc_value
context_instance.topic_error = (exc_type, exc_value, exc_traceback)
else:
topic = copy.deepcopy(context_instance._get_first_available_topic())

Expand Down Expand Up @@ -98,8 +100,10 @@ def run_vow(self, tests_col, topic, context_instance, member, member_name):
def async_run_vow(self, tests_col, topic, context_instance, member, member_name):
filename, lineno = self.file_info_for(member)
result_obj = {
'context_instance': context_instance,
'name': member_name,
'result': None,
'topic': topic,
'error': None,
'succeeded': False,
'file': filename,
Expand Down
2 changes: 1 addition & 1 deletion pyvows/version.py
Expand Up @@ -8,4 +8,4 @@
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2011 Bernardo Heynemann heynemann@gmail.com

__version__ = (0, 4, 7)
__version__ = (0, 4, 8)

0 comments on commit e84e5e9

Please sign in to comment.