Author terry.reedy
Recipients Kit Choi, terry.reedy
Date 2019-09-27.21:00:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
A function can fail to return an expected object by either returning a wrong object or raising an (unexpected) exception.  The assertXyz methods, which ultimately raise AssertionError or something similar, are mostly about catching the first kind of failure, but tests should also catch and report the second kind.  The traceback shows the kind of failure.  The assertXyx failures add additional details after the traceback.

import unittest

class T(unittest.TestCase):
    def test_f(self): raise TypeError()


# Properly results in

Traceback (most recent call last):
  File "F:\Python\a\", line 4, in test_f
    def test_f(self): raise TypeError()

Ran 1 test in 0.050s

FAILED (errors=1)
Date User Action Args
2019-09-27 21:00:16terry.reedysetrecipients: + terry.reedy, Kit Choi
2019-09-27 21:00:16terry.reedysetmessageid: <>
2019-09-27 21:00:16terry.reedylinkissue38296 messages
2019-09-27 21:00:16terry.reedycreate