Skip to content

- show traceback when test failed #419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions python-stdlib/unittest/unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,18 @@ def wasSuccessful(self):
return self.errorsNum == 0 and self.failuresNum == 0


def print_exception(e):
print("-" * 80)

try:
sys.print_exception(e, sys.stdout)
except Exception:
# just print exception
print("EXCEPTION:", e)

print("-" * 80)


# TODO: Uncompliant
def run_class(c, test_result):
o = c()
Expand All @@ -202,11 +214,10 @@ def run_class(c, test_result):
except SkipTest as e:
print(" skipped:", e.args[0])
test_result.skippedNum += 1
except:
except Exception as e:
print(" FAIL")
test_result.failuresNum += 1
# Uncomment to investigate failure in detail
# raise
print_exception(e)
continue
finally:
tear_down()
Expand Down