Skip to content Skip to sidebar Skip to footer

No Active Exception To Reraise

A brief background first. I have to run some unit tests. Only issue is that the client wants the failed tests to be reported in form of a word document with some additional informa

Solution 1:

If it's losing the reference to the error somehow, try passing it explicitly using except AssertionError as err.

class MyTestCase(unittest.TestCase):
    def test_something(self):
        try:
            x = 1
            y = 2
            self.assertEqual(x, y)
        except AssertionError as err:
            writeToDocument(x, y, self.id().split('.')[-1], 'These values should be equal')
            raise err

if __name__ == '__main__':
    unittest.main()

Post a Comment for "No Active Exception To Reraise"