Getting Extended Error Information

B

bala

Hi,I Need Clear Explanaiation of this below code...Bcos my requirement is similar to the below codeI found this code example code in this link http://www.python.org/doc/lib/unittest-error-info.htmlrunner is not returning the MyTestResult class object, instead it is returning the TestResult Class object.import unittest

class MyTestCase(unittest.TestCase):
def defaultTestResult(self):
return MyTestResult()

class MyTestResult(unittest.TestResult):
def __init__(self):
self.errors_tb = []
self.failures_tb = []

def addError(self, test, err):
self.errors_tb.append((test, err))
unittest.TestResult.addError(self, test, err)

def addFailure(self, test, err):
self.failures_tb.append((test, err))
unittest.TestResult.addFailure(self, test, err)
suite = unittest.TestSuite()suite.addTest(unittest.makeSuite(MyTestCase))result = unittest.TextTestRunner(verbosity=2).run(suite)if you run this code,defaultTestResult(self) method not get called....Pls tell me how to extract the error information from MyTestResult classI will be thankfull to you...if u give a solution for the above problem.RegardsBala
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top