This question already has an answer here:
- Customize AssertionError in Python 3 answers
I want to customize my error in unittest. I have code
from exceptions import AssertionError
class AssertionError(AssertionError):
def __str__(self):
return super(AssertionError, self).__str__() + " SOME TEXT"
but during test execution I don't see my text 'SOME TEXT'
.
class TestCase(unittest.TestCase):
def test1111(self):
self.assertTrue(False, "FAIL")
I expected to see:
AssertionError: FAIL SOME TEXT
Overriding works for assert statement but doesn't work in test.
Aucun commentaire:
Enregistrer un commentaire