mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-19942: Do out best to fetch error message even if it is not set for step
Behave 1.2.6 seems to be buggy and step.error_message is None for exceptions, so we fetch it from step.exception or traceback module directly
This commit is contained in:
@@ -148,13 +148,19 @@ class _BehaveRunner(_bdd_utils.BddRunner):
|
||||
# Correct way is to use element.errormessage
|
||||
# but assertions do not have trace there (due to Behave internals)
|
||||
# do, we collect it manually
|
||||
error_message = element.error_message
|
||||
trace = ""
|
||||
if isinstance(element.exception, AssertionError):
|
||||
trace = u"".join([utils.to_unicode(l) for l in traceback.format_tb(element.exc_traceback)])
|
||||
|
||||
error_message = utils.to_unicode(element.error_message)
|
||||
# May be empty https://github.com/behave/behave/issues/468 for some exceptions
|
||||
if not trace and not error_message:
|
||||
error_message = traceback.format_exc()
|
||||
if not error_message:
|
||||
# Format exception as last resort
|
||||
error_message = element.exception
|
||||
|
||||
self._test_failed(step_name, error_message, trace, duration=element.duration)
|
||||
self._test_failed(step_name, utils.to_unicode(error_message), trace, duration=element.duration)
|
||||
elif element.status == 'undefined':
|
||||
self._test_undefined(step_name, element.location)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user