Package buildbot :: Package util :: Module monkeypatches
[frames] | no frames]

Source Code for Module buildbot.util.monkeypatches

 1  from twisted.trial import unittest 
 2   
3 -def add_debugging_monkeypatches():
4 """ 5 DO NOT CALL THIS DIRECTLY 6 7 This adds a few "harmless" monkeypatches which make it easier to debug 8 failing tests. It is called automatically by buildbot.test.__init__. 9 """ 10 from twisted.application.service import Service 11 old_startService = Service.startService 12 old_stopService = Service.stopService 13 def startService(self): 14 assert not self.running 15 return old_startService(self)
16 def stopService(self): 17 assert self.running 18 return old_stopService(self) 19 Service.startService = startService 20 Service.stopService = stopService 21 22 # make unittest.TestCase have a patch method, even if it just skips 23 # the test. 24 def nopatch(self, *args): 25 raise unittest.SkipTest('unittest.patch is not available') 26 if not hasattr(unittest.TestCase, 'patch'): 27 unittest.TestCase.patch = nopatch 28