[Twisted-Python] Unit Testing in twisted 2.0

I've been following the recent thread on the problems with twisted.trial and since it is evidently broken I am hesitant about using it. Instead I create a class that performs all of my tests and sets class attributes with the results. I can then create this class once (at the module level) and then use the standard unittest module to check the results. For example (this is untested code, I'm just trying to briefly illustrate the approach I'm taking): class PerformTests: def __init__(self): self.reactorStartedResults=False self.reactorStoppedResults=False reactor.callLater(0,self.reactorStarted) reactor.run() self.reactorStoppedResults=True def reactorStarted(self): self.reactorStartedResults=True # Issue another test here with .addboth(self.nextTestMethodName) or stop reactor: reactor.stop() performTests=PerformTests() class Test(unittest.TestCase): def testReactorStart(self): self.assert_(performTests.self.reactorStartedResults) def testReactorStopped(self): self.assert_(performTests.self.reactorStoppedResults) # other tests Should I use twisted.trial despite it's problems? If not, is there a better way to implement unit testing then the approach illustrated above? Any suggestions will be appreciated. Thanks, Shawn Church sl_church@sbcglobal.net
participants (2)
-
Eric Mangold
-
Shawn Church