我用我自己的类覆盖unittest.TestCase
,我想在其中添加一些额外的功能assertEqual
:
class MyTestCase(unittest.TestCase):
def __init__(self,*args, **kwargs):
unittest.TestCase.__init__(self, *args, **kwargs)
def _write_to_log(self):
print "writing to log..."
def assertEqual(self, first, second, msg=None):
self._write_to_log()
unittest.TestCase.assertEqual(first, second, msg)
但我得到了TypeError: unbound method assertEqual() must be called with TestCase instance as first argument (got int instance instead)
?